2023-06-20 13:54:02 +08:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"log"
|
|
|
|
"os"
|
|
|
|
"reflect"
|
|
|
|
|
|
|
|
"github.com/pocketbase/pocketbase/plugins/jsvm"
|
|
|
|
"github.com/pocketbase/tygoja"
|
|
|
|
)
|
|
|
|
|
|
|
|
const heading = `
|
|
|
|
// -------------------------------------------------------------------
|
|
|
|
// baseBinds
|
|
|
|
// -------------------------------------------------------------------
|
|
|
|
|
2023-06-29 02:39:57 +08:00
|
|
|
/**
|
|
|
|
* $app is the current running PocketBase instance that is globally
|
|
|
|
* available in each .pb.js file.
|
|
|
|
*
|
|
|
|
* @namespace
|
|
|
|
* @group PocketBase
|
|
|
|
*/
|
2023-06-22 01:36:57 +08:00
|
|
|
declare var $app: pocketbase.PocketBase
|
2023-06-20 13:54:02 +08:00
|
|
|
|
2023-06-26 01:19:01 +08:00
|
|
|
/**
|
|
|
|
* $arrayOf creates a placeholder array of the specified models.
|
|
|
|
* Usually used to populate DB result into an array of models.
|
|
|
|
*
|
|
|
|
* Example:
|
|
|
|
*
|
|
|
|
* ` + "```" + `js
|
|
|
|
* const records = $arrayOf(new Record)
|
|
|
|
*
|
|
|
|
* $app.dao().recordQuery(collection).limit(10).all(records)
|
|
|
|
* ` + "```" + `
|
2023-06-29 02:39:57 +08:00
|
|
|
*
|
|
|
|
* @group PocketBase
|
2023-06-26 01:19:01 +08:00
|
|
|
*/
|
|
|
|
declare function $arrayOf<T>(model: T): Array<T>;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* DynamicModel creates a new dynamic model with fields from the provided data shape.
|
|
|
|
*
|
|
|
|
* Example:
|
|
|
|
*
|
|
|
|
* ` + "```" + `js
|
|
|
|
* const model = new DynamicModel({
|
|
|
|
* name: ""
|
|
|
|
* age: 0,
|
|
|
|
* active: false,
|
|
|
|
* roles: [],
|
|
|
|
* meta: {}
|
|
|
|
* })
|
|
|
|
* ` + "```" + `
|
2023-06-29 02:39:57 +08:00
|
|
|
*
|
|
|
|
* @group PocketBase
|
2023-06-26 01:19:01 +08:00
|
|
|
*/
|
|
|
|
declare class DynamicModel {
|
|
|
|
constructor(shape?: { [key:string]: any })
|
|
|
|
}
|
|
|
|
|
2023-06-29 02:39:57 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Record model class.
|
|
|
|
*
|
|
|
|
* ` + "```" + `js
|
|
|
|
* const collection = $app.dao().findCollectionByNameOrId("article")
|
|
|
|
*
|
|
|
|
* const record = new Record(collection, {
|
|
|
|
* title: "Lorem ipsum"
|
|
|
|
* })
|
|
|
|
*
|
|
|
|
* // or set field values after the initialization
|
|
|
|
* record.set("description", "...")
|
|
|
|
* ` + "```" + `
|
|
|
|
*
|
|
|
|
* @group PocketBase
|
|
|
|
*/
|
|
|
|
declare const Record: {
|
|
|
|
new(collection?: models.Collection, data?: { [key:string]: any }): models.Record
|
|
|
|
|
|
|
|
// note: declare as "newable" const due to conflict with the Record TS utility type
|
2023-06-20 13:54:02 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
interface Collection extends models.Collection{} // merge
|
2023-06-29 02:39:57 +08:00
|
|
|
/**
|
|
|
|
* Collection model class.
|
|
|
|
*
|
|
|
|
* ` + "```" + `js
|
|
|
|
* const collection = new Collection({
|
|
|
|
* name: "article",
|
|
|
|
* type: "base",
|
|
|
|
* listRule: "@request.auth.id != '' || status = 'public'",
|
|
|
|
* viewRule: "@request.auth.id != '' || status = 'public'",
|
|
|
|
* deleteRule: "@request.auth.id != ''",
|
|
|
|
* schema: [
|
|
|
|
* {
|
|
|
|
* name: "title",
|
|
|
|
* type: "text",
|
|
|
|
* required: true,
|
|
|
|
* options: { min: 6, max: 100 },
|
|
|
|
* },
|
|
|
|
* {
|
|
|
|
* name: "description",
|
|
|
|
* type: "text",
|
|
|
|
* },
|
|
|
|
* ]
|
|
|
|
* })
|
|
|
|
* ` + "```" + `
|
|
|
|
*
|
|
|
|
* @group PocketBase
|
|
|
|
*/
|
2023-06-20 13:54:02 +08:00
|
|
|
declare class Collection implements models.Collection {
|
|
|
|
constructor(data?: Partial<models.Collection>)
|
|
|
|
}
|
|
|
|
|
|
|
|
interface Admin extends models.Admin{} // merge
|
2023-06-29 02:39:57 +08:00
|
|
|
/**
|
|
|
|
* Admin model class.
|
|
|
|
*
|
|
|
|
* ` + "```" + `js
|
|
|
|
* const admin = new Admin()
|
|
|
|
* admin.email = "test@example.com"
|
|
|
|
* admin.setPassword(1234567890)
|
|
|
|
* ` + "```" + `
|
|
|
|
*
|
|
|
|
* @group PocketBase
|
|
|
|
*/
|
2023-06-20 13:54:02 +08:00
|
|
|
declare class Admin implements models.Admin {
|
|
|
|
constructor(data?: Partial<models.Admin>)
|
|
|
|
}
|
|
|
|
|
|
|
|
interface Schema extends schema.Schema{} // merge
|
2023-06-29 02:39:57 +08:00
|
|
|
/**
|
|
|
|
* Schema model class, usually used to define the Collection.schema field.
|
|
|
|
*
|
|
|
|
* @group PocketBase
|
|
|
|
*/
|
2023-06-20 13:54:02 +08:00
|
|
|
declare class Schema implements schema.Schema {
|
|
|
|
constructor(data?: Partial<schema.Schema>)
|
|
|
|
}
|
|
|
|
|
|
|
|
interface SchemaField extends schema.SchemaField{} // merge
|
2023-06-29 02:39:57 +08:00
|
|
|
/**
|
|
|
|
* SchemaField model class, usually used as part of the Schema model.
|
|
|
|
*
|
|
|
|
* @group PocketBase
|
|
|
|
*/
|
2023-06-20 13:54:02 +08:00
|
|
|
declare class SchemaField implements schema.SchemaField {
|
|
|
|
constructor(data?: Partial<schema.SchemaField>)
|
|
|
|
}
|
|
|
|
|
2023-06-22 01:36:57 +08:00
|
|
|
interface MailerMessage extends mailer.Message{} // merge
|
2023-06-29 02:39:57 +08:00
|
|
|
/**
|
|
|
|
* MailerMessage defines a single email message.
|
|
|
|
*
|
|
|
|
* ` + "```" + `js
|
|
|
|
* const message = new MailerMessage({
|
|
|
|
* from: {
|
|
|
|
* address: $app.settings().meta.senderAddress,
|
|
|
|
* name: $app.settings().meta.senderName,
|
|
|
|
* },
|
|
|
|
* to: [{address: "test@example.com"}],
|
|
|
|
* subject: "YOUR_SUBJECT...",
|
|
|
|
* html: "YOUR_HTML_BODY...",
|
|
|
|
* })
|
|
|
|
*
|
|
|
|
* $app.newMailClient().send(message)
|
|
|
|
* ` + "```" + `
|
|
|
|
*
|
|
|
|
* @group PocketBase
|
|
|
|
*/
|
2023-06-22 01:40:43 +08:00
|
|
|
declare class MailerMessage implements mailer.Message {
|
2023-06-20 13:54:02 +08:00
|
|
|
constructor(message?: Partial<mailer.Message>)
|
|
|
|
}
|
|
|
|
|
2023-06-22 01:36:57 +08:00
|
|
|
interface Command extends cobra.Command{} // merge
|
2023-06-29 02:39:57 +08:00
|
|
|
/**
|
|
|
|
* Command defines a single console command.
|
|
|
|
*
|
|
|
|
* ` + "```" + `js
|
|
|
|
* const command = new Command({
|
|
|
|
* use: "hello",
|
|
|
|
* run: (cmd, args) => { console.log("Hello world!") },
|
|
|
|
* })
|
|
|
|
*
|
|
|
|
* $app.rootCmd.addCommand(command);
|
|
|
|
* ` + "```" + `
|
|
|
|
*
|
|
|
|
* @group PocketBase
|
|
|
|
*/
|
2023-06-22 01:40:43 +08:00
|
|
|
declare class Command implements cobra.Command {
|
2023-06-22 01:36:57 +08:00
|
|
|
constructor(cmd?: Partial<cobra.Command>)
|
|
|
|
}
|
|
|
|
|
2023-06-20 13:54:02 +08:00
|
|
|
interface ValidationError extends ozzo_validation.Error{} // merge
|
2023-06-29 02:39:57 +08:00
|
|
|
/**
|
|
|
|
* ValidationError defines a single formatted data validation error,
|
|
|
|
* usually used as part of a error response.
|
|
|
|
*
|
|
|
|
* ` + "```" + `js
|
|
|
|
* new ValidationError("invalid_title", "Title is not valid")
|
|
|
|
* ` + "```" + `
|
|
|
|
*
|
|
|
|
* @group PocketBase
|
|
|
|
*/
|
2023-06-20 13:54:02 +08:00
|
|
|
declare class ValidationError implements ozzo_validation.Error {
|
2023-06-29 02:39:57 +08:00
|
|
|
constructor(code?: string, message?: string)
|
2023-06-20 13:54:02 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
interface Dao extends daos.Dao{} // merge
|
2023-06-29 02:39:57 +08:00
|
|
|
/**
|
|
|
|
* @inheritDoc
|
|
|
|
* @group PocketBase
|
|
|
|
*/
|
2023-06-20 13:54:02 +08:00
|
|
|
declare class Dao implements daos.Dao {
|
|
|
|
constructor(concurrentDB?: dbx.Builder, nonconcurrentDB?: dbx.Builder)
|
|
|
|
}
|
|
|
|
|
|
|
|
// -------------------------------------------------------------------
|
|
|
|
// dbxBinds
|
|
|
|
// -------------------------------------------------------------------
|
|
|
|
|
2023-06-29 02:39:57 +08:00
|
|
|
/**
|
|
|
|
* @group PocketBase
|
|
|
|
*/
|
2023-06-20 13:54:02 +08:00
|
|
|
declare namespace $dbx {
|
|
|
|
/**
|
|
|
|
* {@inheritDoc dbx.HashExp}
|
|
|
|
*/
|
|
|
|
export function hashExp(pairs: { [key:string]: any }): dbx.Expression
|
|
|
|
|
|
|
|
let _in: dbx._in
|
|
|
|
export { _in as in }
|
|
|
|
|
|
|
|
export let exp: dbx.newExp
|
|
|
|
export let not: dbx.not
|
|
|
|
export let and: dbx.and
|
|
|
|
export let or: dbx.or
|
|
|
|
export let notIn: dbx.notIn
|
|
|
|
export let like: dbx.like
|
|
|
|
export let orLike: dbx.orLike
|
|
|
|
export let notLike: dbx.notLike
|
|
|
|
export let orNotLike: dbx.orNotLike
|
|
|
|
export let exists: dbx.exists
|
|
|
|
export let notExists: dbx.notExists
|
|
|
|
export let between: dbx.between
|
|
|
|
export let notBetween: dbx.notBetween
|
|
|
|
}
|
|
|
|
|
|
|
|
// -------------------------------------------------------------------
|
|
|
|
// tokensBinds
|
|
|
|
// -------------------------------------------------------------------
|
|
|
|
|
2023-06-29 02:39:57 +08:00
|
|
|
/**
|
|
|
|
* @group PocketBase
|
|
|
|
*/
|
2023-06-20 13:54:02 +08:00
|
|
|
declare namespace $tokens {
|
|
|
|
let adminAuthToken: tokens.newAdminAuthToken
|
|
|
|
let adminResetPasswordToken: tokens.newAdminResetPasswordToken
|
|
|
|
let adminFileToken: tokens.newAdminFileToken
|
|
|
|
let recordAuthToken: tokens.newRecordAuthToken
|
|
|
|
let recordVerifyToken: tokens.newRecordVerifyToken
|
|
|
|
let recordResetPasswordToken: tokens.newRecordResetPasswordToken
|
|
|
|
let recordChangeEmailToken: tokens.newRecordChangeEmailToken
|
|
|
|
let recordFileToken: tokens.newRecordFileToken
|
|
|
|
}
|
|
|
|
|
|
|
|
// -------------------------------------------------------------------
|
|
|
|
// securityBinds
|
|
|
|
// -------------------------------------------------------------------
|
|
|
|
|
2023-06-29 02:39:57 +08:00
|
|
|
/**
|
|
|
|
* @group PocketBase
|
|
|
|
*/
|
2023-06-20 13:54:02 +08:00
|
|
|
declare namespace $security {
|
|
|
|
let randomString: security.randomString
|
|
|
|
let randomStringWithAlphabet: security.randomStringWithAlphabet
|
|
|
|
let pseudorandomString: security.pseudorandomString
|
|
|
|
let pseudorandomStringWithAlphabet: security.pseudorandomStringWithAlphabet
|
|
|
|
let parseUnverifiedToken: security.parseUnverifiedJWT
|
|
|
|
let parseToken: security.parseJWT
|
|
|
|
let createToken: security.newToken
|
|
|
|
}
|
|
|
|
|
|
|
|
// -------------------------------------------------------------------
|
|
|
|
// filesystemBinds
|
|
|
|
// -------------------------------------------------------------------
|
|
|
|
|
2023-06-29 02:39:57 +08:00
|
|
|
/**
|
|
|
|
* @group PocketBase
|
|
|
|
*/
|
2023-06-20 13:54:02 +08:00
|
|
|
declare namespace $filesystem {
|
|
|
|
let fileFromPath: filesystem.newFileFromPath
|
|
|
|
let fileFromBytes: filesystem.newFileFromBytes
|
|
|
|
let fileFromMultipart: filesystem.newFileFromMultipart
|
|
|
|
}
|
|
|
|
|
|
|
|
// -------------------------------------------------------------------
|
|
|
|
// formsBinds
|
|
|
|
// -------------------------------------------------------------------
|
|
|
|
|
|
|
|
interface AdminLoginForm extends forms.AdminLogin{} // merge
|
2023-06-29 02:39:57 +08:00
|
|
|
/**
|
|
|
|
* @inheritDoc
|
|
|
|
* @group PocketBase
|
|
|
|
*/
|
2023-06-20 13:54:02 +08:00
|
|
|
declare class AdminLoginForm implements forms.AdminLogin {
|
|
|
|
constructor(app: core.App)
|
|
|
|
}
|
|
|
|
|
|
|
|
interface AdminPasswordResetConfirmForm extends forms.AdminPasswordResetConfirm{} // merge
|
2023-06-29 02:39:57 +08:00
|
|
|
/**
|
|
|
|
* @inheritDoc
|
|
|
|
* @group PocketBase
|
|
|
|
*/
|
2023-06-20 13:54:02 +08:00
|
|
|
declare class AdminPasswordResetConfirmForm implements forms.AdminPasswordResetConfirm {
|
|
|
|
constructor(app: core.App)
|
|
|
|
}
|
|
|
|
|
|
|
|
interface AdminPasswordResetRequestForm extends forms.AdminPasswordResetRequest{} // merge
|
2023-06-29 02:39:57 +08:00
|
|
|
/**
|
|
|
|
* @inheritDoc
|
|
|
|
* @group PocketBase
|
|
|
|
*/
|
2023-06-20 13:54:02 +08:00
|
|
|
declare class AdminPasswordResetRequestForm implements forms.AdminPasswordResetRequest {
|
|
|
|
constructor(app: core.App)
|
|
|
|
}
|
|
|
|
|
|
|
|
interface AdminUpsertForm extends forms.AdminUpsert{} // merge
|
2023-06-29 02:39:57 +08:00
|
|
|
/**
|
|
|
|
* @inheritDoc
|
|
|
|
* @group PocketBase
|
|
|
|
*/
|
2023-06-20 13:54:02 +08:00
|
|
|
declare class AdminUpsertForm implements forms.AdminUpsert {
|
|
|
|
constructor(app: core.App, admin: models.Admin)
|
|
|
|
}
|
|
|
|
|
|
|
|
interface AppleClientSecretCreateForm extends forms.AppleClientSecretCreate{} // merge
|
2023-06-29 02:39:57 +08:00
|
|
|
/**
|
|
|
|
* @inheritDoc
|
|
|
|
* @group PocketBase
|
|
|
|
*/
|
2023-06-20 13:54:02 +08:00
|
|
|
declare class AppleClientSecretCreateForm implements forms.AppleClientSecretCreate {
|
|
|
|
constructor(app: core.App)
|
|
|
|
}
|
|
|
|
|
|
|
|
interface CollectionUpsertForm extends forms.CollectionUpsert{} // merge
|
2023-06-29 02:39:57 +08:00
|
|
|
/**
|
|
|
|
* @inheritDoc
|
|
|
|
* @group PocketBase
|
|
|
|
*/
|
2023-06-20 13:54:02 +08:00
|
|
|
declare class CollectionUpsertForm implements forms.CollectionUpsert {
|
|
|
|
constructor(app: core.App, collection: models.Collection)
|
|
|
|
}
|
|
|
|
|
|
|
|
interface CollectionsImportForm extends forms.CollectionsImport{} // merge
|
2023-06-29 02:39:57 +08:00
|
|
|
/**
|
|
|
|
* @inheritDoc
|
|
|
|
* @group PocketBase
|
|
|
|
*/
|
2023-06-20 13:54:02 +08:00
|
|
|
declare class CollectionsImportForm implements forms.CollectionsImport {
|
|
|
|
constructor(app: core.App)
|
|
|
|
}
|
|
|
|
|
|
|
|
interface RealtimeSubscribeForm extends forms.RealtimeSubscribe{} // merge
|
2023-06-29 02:39:57 +08:00
|
|
|
/**
|
|
|
|
* @inheritDoc
|
|
|
|
* @group PocketBase
|
|
|
|
*/
|
2023-06-20 13:54:02 +08:00
|
|
|
declare class RealtimeSubscribeForm implements forms.RealtimeSubscribe {}
|
|
|
|
|
|
|
|
interface RecordEmailChangeConfirmForm extends forms.RecordEmailChangeConfirm{} // merge
|
2023-06-29 02:39:57 +08:00
|
|
|
/**
|
|
|
|
* @inheritDoc
|
|
|
|
* @group PocketBase
|
|
|
|
*/
|
2023-06-20 13:54:02 +08:00
|
|
|
declare class RecordEmailChangeConfirmForm implements forms.RecordEmailChangeConfirm {
|
|
|
|
constructor(app: core.App, collection: models.Collection)
|
|
|
|
}
|
|
|
|
|
|
|
|
interface RecordEmailChangeRequestForm extends forms.RecordEmailChangeRequest{} // merge
|
2023-06-29 02:39:57 +08:00
|
|
|
/**
|
|
|
|
* @inheritDoc
|
|
|
|
* @group PocketBase
|
|
|
|
*/
|
2023-06-20 13:54:02 +08:00
|
|
|
declare class RecordEmailChangeRequestForm implements forms.RecordEmailChangeRequest {
|
|
|
|
constructor(app: core.App, record: models.Record)
|
|
|
|
}
|
|
|
|
|
|
|
|
interface RecordOAuth2LoginForm extends forms.RecordOAuth2Login{} // merge
|
2023-06-29 02:39:57 +08:00
|
|
|
/**
|
|
|
|
* @inheritDoc
|
|
|
|
* @group PocketBase
|
|
|
|
*/
|
2023-06-20 13:54:02 +08:00
|
|
|
declare class RecordOAuth2LoginForm implements forms.RecordOAuth2Login {
|
|
|
|
constructor(app: core.App, collection: models.Collection, optAuthRecord?: models.Record)
|
|
|
|
}
|
|
|
|
|
|
|
|
interface RecordPasswordLoginForm extends forms.RecordPasswordLogin{} // merge
|
2023-06-29 02:39:57 +08:00
|
|
|
/**
|
|
|
|
* @inheritDoc
|
|
|
|
* @group PocketBase
|
|
|
|
*/
|
2023-06-20 13:54:02 +08:00
|
|
|
declare class RecordPasswordLoginForm implements forms.RecordPasswordLogin {
|
|
|
|
constructor(app: core.App, collection: models.Collection)
|
|
|
|
}
|
|
|
|
|
|
|
|
interface RecordPasswordResetConfirmForm extends forms.RecordPasswordResetConfirm{} // merge
|
2023-06-29 02:39:57 +08:00
|
|
|
/**
|
|
|
|
* @inheritDoc
|
|
|
|
* @group PocketBase
|
|
|
|
*/
|
2023-06-20 13:54:02 +08:00
|
|
|
declare class RecordPasswordResetConfirmForm implements forms.RecordPasswordResetConfirm {
|
|
|
|
constructor(app: core.App, collection: models.Collection)
|
|
|
|
}
|
|
|
|
|
|
|
|
interface RecordPasswordResetRequestForm extends forms.RecordPasswordResetRequest{} // merge
|
2023-06-29 02:39:57 +08:00
|
|
|
/**
|
|
|
|
* @inheritDoc
|
|
|
|
* @group PocketBase
|
|
|
|
*/
|
2023-06-20 13:54:02 +08:00
|
|
|
declare class RecordPasswordResetRequestForm implements forms.RecordPasswordResetRequest {
|
|
|
|
constructor(app: core.App, collection: models.Collection)
|
|
|
|
}
|
|
|
|
|
|
|
|
interface RecordUpsertForm extends forms.RecordUpsert{} // merge
|
2023-06-29 02:39:57 +08:00
|
|
|
/**
|
|
|
|
* @inheritDoc
|
|
|
|
* @group PocketBase
|
|
|
|
*/
|
2023-06-20 13:54:02 +08:00
|
|
|
declare class RecordUpsertForm implements forms.RecordUpsert {
|
|
|
|
constructor(app: core.App, record: models.Record)
|
|
|
|
}
|
|
|
|
|
|
|
|
interface RecordVerificationConfirmForm extends forms.RecordVerificationConfirm{} // merge
|
2023-06-29 02:39:57 +08:00
|
|
|
/**
|
|
|
|
* @inheritDoc
|
|
|
|
* @group PocketBase
|
|
|
|
*/
|
2023-06-20 13:54:02 +08:00
|
|
|
declare class RecordVerificationConfirmForm implements forms.RecordVerificationConfirm {
|
|
|
|
constructor(app: core.App, collection: models.Collection)
|
|
|
|
}
|
|
|
|
|
|
|
|
interface RecordVerificationRequestForm extends forms.RecordVerificationRequest{} // merge
|
2023-06-29 02:39:57 +08:00
|
|
|
/**
|
|
|
|
* @inheritDoc
|
|
|
|
* @group PocketBase
|
|
|
|
*/
|
2023-06-20 13:54:02 +08:00
|
|
|
declare class RecordVerificationRequestForm implements forms.RecordVerificationRequest {
|
|
|
|
constructor(app: core.App, collection: models.Collection)
|
|
|
|
}
|
|
|
|
|
|
|
|
interface SettingsUpsertForm extends forms.SettingsUpsert{} // merge
|
2023-06-29 02:39:57 +08:00
|
|
|
/**
|
|
|
|
* @inheritDoc
|
|
|
|
* @group PocketBase
|
|
|
|
*/
|
2023-06-20 13:54:02 +08:00
|
|
|
declare class SettingsUpsertForm implements forms.SettingsUpsert {
|
|
|
|
constructor(app: core.App)
|
|
|
|
}
|
|
|
|
|
|
|
|
interface TestEmailSendForm extends forms.TestEmailSend{} // merge
|
2023-06-29 02:39:57 +08:00
|
|
|
/**
|
|
|
|
* @inheritDoc
|
|
|
|
* @group PocketBase
|
|
|
|
*/
|
2023-06-20 13:54:02 +08:00
|
|
|
declare class TestEmailSendForm implements forms.TestEmailSend {
|
|
|
|
constructor(app: core.App)
|
|
|
|
}
|
|
|
|
|
|
|
|
interface TestS3FilesystemForm extends forms.TestS3Filesystem{} // merge
|
2023-06-29 02:39:57 +08:00
|
|
|
/**
|
|
|
|
* @inheritDoc
|
|
|
|
* @group PocketBase
|
|
|
|
*/
|
2023-06-20 13:54:02 +08:00
|
|
|
declare class TestS3FilesystemForm implements forms.TestS3Filesystem {
|
|
|
|
constructor(app: core.App)
|
|
|
|
}
|
|
|
|
|
|
|
|
// -------------------------------------------------------------------
|
|
|
|
// apisBinds
|
|
|
|
// -------------------------------------------------------------------
|
|
|
|
|
|
|
|
interface Route extends echo.Route{} // merge
|
2023-06-29 02:39:57 +08:00
|
|
|
/**
|
|
|
|
* Route specifies a new route definition.
|
|
|
|
* This is usually used when registering routes with router.addRoute().
|
|
|
|
*
|
|
|
|
* ` + "```" + `js
|
|
|
|
* const route = new Route({
|
|
|
|
* path: "/hello",
|
|
|
|
* handler: (c) => {
|
|
|
|
* c.string(200, "hello world!")
|
|
|
|
* },
|
|
|
|
* middlewares: [$apis.activityLogger($app)]
|
|
|
|
* })
|
|
|
|
* ` + "```" + `
|
|
|
|
*
|
|
|
|
* @group PocketBase
|
|
|
|
*/
|
2023-06-20 13:54:02 +08:00
|
|
|
declare class Route implements echo.Route {
|
|
|
|
constructor(data?: Partial<echo.Route>)
|
|
|
|
}
|
|
|
|
|
|
|
|
interface ApiError extends apis.ApiError{} // merge
|
2023-06-29 02:39:57 +08:00
|
|
|
/**
|
|
|
|
* @group PocketBase
|
|
|
|
*/
|
2023-06-20 13:54:02 +08:00
|
|
|
declare class ApiError implements apis.ApiError {
|
|
|
|
constructor(status?: number, message?: string, data?: any)
|
|
|
|
}
|
|
|
|
|
2023-06-26 01:19:01 +08:00
|
|
|
interface NotFoundError extends apis.ApiError{} // merge
|
2023-06-29 02:39:57 +08:00
|
|
|
/**
|
|
|
|
* @group PocketBase
|
|
|
|
*/
|
2023-06-26 01:19:01 +08:00
|
|
|
declare class NotFoundError implements apis.ApiError {
|
2023-06-24 03:20:13 +08:00
|
|
|
constructor(message?: string, data?: any)
|
|
|
|
}
|
|
|
|
|
2023-06-26 01:19:01 +08:00
|
|
|
interface BadRequestError extends apis.ApiError{} // merge
|
2023-06-29 02:39:57 +08:00
|
|
|
/**
|
|
|
|
* @group PocketBase
|
|
|
|
*/
|
2023-06-26 01:19:01 +08:00
|
|
|
declare class BadRequestError implements apis.ApiError {
|
2023-06-24 03:20:13 +08:00
|
|
|
constructor(message?: string, data?: any)
|
|
|
|
}
|
|
|
|
|
2023-06-26 01:19:01 +08:00
|
|
|
interface ForbiddenError extends apis.ApiError{} // merge
|
2023-06-29 02:39:57 +08:00
|
|
|
/**
|
|
|
|
* @group PocketBase
|
|
|
|
*/
|
2023-06-26 01:19:01 +08:00
|
|
|
declare class ForbiddenError implements apis.ApiError {
|
2023-06-24 03:20:13 +08:00
|
|
|
constructor(message?: string, data?: any)
|
|
|
|
}
|
|
|
|
|
2023-06-26 01:19:01 +08:00
|
|
|
interface UnauthorizedError extends apis.ApiError{} // merge
|
2023-06-29 02:39:57 +08:00
|
|
|
/**
|
|
|
|
* @group PocketBase
|
|
|
|
*/
|
2023-06-26 01:19:01 +08:00
|
|
|
declare class UnauthorizedError implements apis.ApiError {
|
2023-06-24 03:20:13 +08:00
|
|
|
constructor(message?: string, data?: any)
|
|
|
|
}
|
|
|
|
|
2023-06-29 02:39:57 +08:00
|
|
|
/**
|
|
|
|
* @group PocketBase
|
|
|
|
*/
|
2023-06-20 13:54:02 +08:00
|
|
|
declare namespace $apis {
|
2023-06-27 19:45:04 +08:00
|
|
|
let requireRecordAuth: apis.requireRecordAuth
|
|
|
|
let requireAdminAuth: apis.requireAdminAuth
|
|
|
|
let requireAdminAuthOnlyIfAny: apis.requireAdminAuthOnlyIfAny
|
|
|
|
let requireAdminOrRecordAuth: apis.requireAdminOrRecordAuth
|
|
|
|
let requireAdminOrOwnerAuth: apis.requireAdminOrOwnerAuth
|
|
|
|
let activityLogger: apis.activityLogger
|
|
|
|
let requestData: apis.requestData
|
|
|
|
let recordAuthResponse: apis.recordAuthResponse
|
|
|
|
let enrichRecord: apis.enrichRecord
|
|
|
|
let enrichRecords: apis.enrichRecords
|
2023-06-20 13:54:02 +08:00
|
|
|
}
|
2023-06-27 19:45:04 +08:00
|
|
|
|
|
|
|
// -------------------------------------------------------------------
|
|
|
|
// migrate only
|
|
|
|
// -------------------------------------------------------------------
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Migrate defines a single migration upgrade/downgrade action.
|
|
|
|
*
|
|
|
|
* Note that this method is available only in pb_migrations context.
|
2023-06-29 02:39:57 +08:00
|
|
|
*
|
|
|
|
* @group PocketBase
|
2023-06-27 19:45:04 +08:00
|
|
|
*/
|
|
|
|
declare function migrate(
|
|
|
|
up: (db: dbx.Builder) => void,
|
|
|
|
down?: (db: dbx.Builder) => void
|
|
|
|
): void;
|
2023-06-20 13:54:02 +08:00
|
|
|
`
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
mapper := &jsvm.FieldMapper{}
|
|
|
|
|
|
|
|
gen := tygoja.New(tygoja.Config{
|
|
|
|
Packages: map[string][]string{
|
|
|
|
"github.com/go-ozzo/ozzo-validation/v4": {"Error"},
|
|
|
|
"github.com/pocketbase/dbx": {"*"},
|
|
|
|
"github.com/pocketbase/pocketbase/tools/security": {"*"},
|
|
|
|
"github.com/pocketbase/pocketbase/tools/filesystem": {"*"},
|
|
|
|
"github.com/pocketbase/pocketbase/tokens": {"*"},
|
|
|
|
"github.com/pocketbase/pocketbase/apis": {"*"},
|
|
|
|
"github.com/pocketbase/pocketbase/forms": {"*"},
|
2023-06-22 01:36:57 +08:00
|
|
|
"github.com/pocketbase/pocketbase": {"*"},
|
2023-06-20 13:54:02 +08:00
|
|
|
},
|
|
|
|
FieldNameFormatter: func(s string) string {
|
|
|
|
return mapper.FieldName(nil, reflect.StructField{Name: s})
|
|
|
|
},
|
|
|
|
MethodNameFormatter: func(s string) string {
|
|
|
|
return mapper.MethodName(nil, reflect.Method{Name: s})
|
|
|
|
},
|
|
|
|
Indent: " ", // use only a single space to reduce slight the size
|
|
|
|
WithPackageFunctions: true,
|
|
|
|
Heading: heading,
|
|
|
|
})
|
|
|
|
|
|
|
|
result, err := gen.Generate()
|
|
|
|
if err != nil {
|
|
|
|
log.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
if err := os.WriteFile("./generated/types.d.ts", []byte(result), 0644); err != nil {
|
|
|
|
log.Fatal(err)
|
|
|
|
}
|
|
|
|
}
|