@constructive-sdk/cli 0.20.7 → 0.20.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/admin/orm/client.d.ts +30 -0
- package/admin/orm/client.js +41 -1
- package/admin/orm/realtime.d.ts +142 -0
- package/admin/orm/realtime.js +104 -0
- package/auth/orm/client.d.ts +30 -0
- package/auth/orm/client.js +41 -1
- package/auth/orm/realtime.d.ts +142 -0
- package/auth/orm/realtime.js +104 -0
- package/esm/admin/orm/client.d.ts +30 -0
- package/esm/admin/orm/client.js +39 -0
- package/esm/admin/orm/realtime.d.ts +142 -0
- package/esm/admin/orm/realtime.js +100 -0
- package/esm/auth/orm/client.d.ts +30 -0
- package/esm/auth/orm/client.js +39 -0
- package/esm/auth/orm/realtime.d.ts +142 -0
- package/esm/auth/orm/realtime.js +100 -0
- package/esm/objects/orm/client.d.ts +30 -0
- package/esm/objects/orm/client.js +39 -0
- package/esm/objects/orm/realtime.d.ts +142 -0
- package/esm/objects/orm/realtime.js +100 -0
- package/esm/public/cli/commands/{append-smart-tags.d.ts → append-field-smart-tags.d.ts} +1 -1
- package/esm/public/cli/commands/{append-smart-tags.js → append-field-smart-tags.js} +3 -3
- package/{public/cli/commands/append-smart-tags.d.ts → esm/public/cli/commands/append-table-smart-tags.d.ts} +1 -1
- package/esm/public/cli/commands/append-table-smart-tags.js +34 -0
- package/esm/public/cli/commands.js +5 -3
- package/esm/public/cli/executor.d.ts +8 -3
- package/esm/public/orm/client.d.ts +30 -0
- package/esm/public/orm/client.js +39 -0
- package/esm/public/orm/index.d.ts +8 -3
- package/esm/public/orm/input-types.d.ts +14 -3
- package/esm/public/orm/mutation/index.d.ts +14 -6
- package/esm/public/orm/mutation/index.js +18 -6
- package/esm/public/orm/realtime.d.ts +142 -0
- package/esm/public/orm/realtime.js +100 -0
- package/objects/orm/client.d.ts +30 -0
- package/objects/orm/client.js +41 -1
- package/objects/orm/realtime.d.ts +142 -0
- package/objects/orm/realtime.js +104 -0
- package/package.json +2 -2
- package/public/cli/commands/append-field-smart-tags.d.ts +8 -0
- package/public/cli/commands/{append-smart-tags.js → append-field-smart-tags.js} +3 -3
- package/public/cli/commands/append-table-smart-tags.d.ts +8 -0
- package/public/cli/commands/append-table-smart-tags.js +36 -0
- package/public/cli/commands.js +5 -3
- package/public/cli/executor.d.ts +8 -3
- package/public/orm/client.d.ts +30 -0
- package/public/orm/client.js +41 -1
- package/public/orm/index.d.ts +8 -3
- package/public/orm/input-types.d.ts +14 -3
- package/public/orm/mutation/index.d.ts +14 -6
- package/public/orm/mutation/index.js +18 -6
- package/public/orm/realtime.d.ts +142 -0
- package/public/orm/realtime.js +104 -0
|
@@ -202,7 +202,8 @@ import copyTemplateToBlueprintCmd from './commands/copy-template-to-blueprint';
|
|
|
202
202
|
import provisionSpatialRelationCmd from './commands/provision-spatial-relation';
|
|
203
203
|
import bootstrapUserCmd from './commands/bootstrap-user';
|
|
204
204
|
import setFieldOrderCmd from './commands/set-field-order';
|
|
205
|
-
import
|
|
205
|
+
import appendFieldSmartTagsCmd from './commands/append-field-smart-tags';
|
|
206
|
+
import appendTableSmartTagsCmd from './commands/append-table-smart-tags';
|
|
206
207
|
import provisionUniqueConstraintCmd from './commands/provision-unique-constraint';
|
|
207
208
|
import provisionFullTextSearchCmd from './commands/provision-full-text-search';
|
|
208
209
|
import provisionIndexCmd from './commands/provision-index';
|
|
@@ -424,7 +425,8 @@ const createCommandMap = () => ({
|
|
|
424
425
|
'provision-spatial-relation': provisionSpatialRelationCmd,
|
|
425
426
|
'bootstrap-user': bootstrapUserCmd,
|
|
426
427
|
'set-field-order': setFieldOrderCmd,
|
|
427
|
-
'append-smart-tags':
|
|
428
|
+
'append-field-smart-tags': appendFieldSmartTagsCmd,
|
|
429
|
+
'append-table-smart-tags': appendTableSmartTagsCmd,
|
|
428
430
|
'provision-unique-constraint': provisionUniqueConstraintCmd,
|
|
429
431
|
'provision-full-text-search': provisionFullTextSearchCmd,
|
|
430
432
|
'provision-index': provisionIndexCmd,
|
|
@@ -448,7 +450,7 @@ const createCommandMap = () => ({
|
|
|
448
450
|
'provision-table': provisionTableCmd,
|
|
449
451
|
'provision-bucket': provisionBucketCmd,
|
|
450
452
|
});
|
|
451
|
-
const usage = "\ncsdk <command>\n\nCommands:\n context Manage API contexts\n auth Manage authentication\n org-get-managers-record orgGetManagersRecord CRUD operations\n org-get-subordinates-record orgGetSubordinatesRecord CRUD operations\n get-all-record getAllRecord CRUD operations\n app-permission appPermission CRUD operations\n org-permission orgPermission CRUD operations\n object object CRUD operations\n app-level-requirement appLevelRequirement CRUD operations\n database database CRUD operations\n schema schema CRUD operations\n table table CRUD operations\n check-constraint checkConstraint CRUD operations\n field field CRUD operations\n spatial-relation spatialRelation CRUD operations\n partition partition CRUD operations\n foreign-key-constraint foreignKeyConstraint CRUD operations\n full-text-search fullTextSearch CRUD operations\n index index CRUD operations\n policy policy CRUD operations\n primary-key-constraint primaryKeyConstraint CRUD operations\n table-grant tableGrant CRUD operations\n trigger trigger CRUD operations\n unique-constraint uniqueConstraint CRUD operations\n view view CRUD operations\n view-table viewTable CRUD operations\n view-grant viewGrant CRUD operations\n view-rule viewRule CRUD operations\n embedding-chunk embeddingChunk CRUD operations\n secure-table-provision secureTableProvision CRUD operations\n relation-provision relationProvision CRUD operations\n session-secrets-module sessionSecretsModule CRUD operations\n identity-providers-module identityProvidersModule CRUD operations\n realtime-module realtimeModule CRUD operations\n schema-grant schemaGrant CRUD operations\n default-privilege defaultPrivilege CRUD operations\n enum enum CRUD operations\n function function CRUD operations\n api-schema apiSchema CRUD operations\n api-module apiModule CRUD operations\n domain domain CRUD operations\n site-metadatum siteMetadatum CRUD operations\n site-module siteModule CRUD operations\n site-theme siteTheme CRUD operations\n cors-setting corsSetting CRUD operations\n trigger-function triggerFunction CRUD operations\n database-transfer databaseTransfer CRUD operations\n api api CRUD operations\n site site CRUD operations\n app app CRUD operations\n api-setting apiSetting CRUD operations\n connected-accounts-module connectedAccountsModule CRUD operations\n crypto-addresses-module cryptoAddressesModule CRUD operations\n crypto-auth-module cryptoAuthModule CRUD operations\n default-ids-module defaultIdsModule CRUD operations\n denormalized-table-field denormalizedTableField CRUD operations\n emails-module emailsModule CRUD operations\n encrypted-secrets-module encryptedSecretsModule CRUD operations\n invites-module invitesModule CRUD operations\n levels-module levelsModule CRUD operations\n limits-module limitsModule CRUD operations\n membership-types-module membershipTypesModule CRUD operations\n memberships-module membershipsModule CRUD operations\n permissions-module permissionsModule CRUD operations\n phone-numbers-module phoneNumbersModule CRUD operations\n profiles-module profilesModule CRUD operations\n secrets-module secretsModule CRUD operations\n sessions-module sessionsModule CRUD operations\n user-auth-module userAuthModule CRUD operations\n users-module usersModule CRUD operations\n blueprint blueprint CRUD operations\n blueprint-template blueprintTemplate CRUD operations\n blueprint-construction blueprintConstruction CRUD operations\n storage-module storageModule CRUD operations\n entity-type-provision entityTypeProvision CRUD operations\n webauthn-credentials-module webauthnCredentialsModule CRUD operations\n webauthn-auth-module webauthnAuthModule CRUD operations\n notifications-module notificationsModule CRUD operations\n database-provision-module databaseProvisionModule CRUD operations\n app-admin-grant appAdminGrant CRUD operations\n app-owner-grant appOwnerGrant CRUD operations\n app-grant appGrant CRUD operations\n org-membership orgMembership CRUD operations\n org-member orgMember CRUD operations\n org-admin-grant orgAdminGrant CRUD operations\n org-owner-grant orgOwnerGrant CRUD operations\n org-member-profile orgMemberProfile CRUD operations\n org-grant orgGrant CRUD operations\n org-chart-edge orgChartEdge CRUD operations\n org-chart-edge-grant orgChartEdgeGrant CRUD operations\n org-permission-default orgPermissionDefault CRUD operations\n app-limit appLimit CRUD operations\n app-limit-credit appLimitCredit CRUD operations\n app-limit-credit-code-item appLimitCreditCodeItem CRUD operations\n app-limit-credit-redemption appLimitCreditRedemption CRUD operations\n org-limit orgLimit CRUD operations\n org-limit-credit orgLimitCredit CRUD operations\n org-limit-aggregate orgLimitAggregate CRUD operations\n app-step appStep CRUD operations\n app-achievement appAchievement CRUD operations\n app-level appLevel CRUD operations\n email email CRUD operations\n phone-number phoneNumber CRUD operations\n crypto-address cryptoAddress CRUD operations\n webauthn-credential webauthnCredential CRUD operations\n app-invite appInvite CRUD operations\n app-claimed-invite appClaimedInvite CRUD operations\n org-invite orgInvite CRUD operations\n org-claimed-invite orgClaimedInvite CRUD operations\n audit-log auditLog CRUD operations\n agent-thread agentThread CRUD operations\n agent-message agentMessage CRUD operations\n agent-task agentTask CRUD operations\n role-type roleType CRUD operations\n identity-provider identityProvider CRUD operations\n ref ref CRUD operations\n store store CRUD operations\n app-permission-default appPermissionDefault CRUD operations\n app-limit-credit-code appLimitCreditCode CRUD operations\n app-limit-caps-default appLimitCapsDefault CRUD operations\n org-limit-caps-default orgLimitCapsDefault CRUD operations\n app-limit-cap appLimitCap CRUD operations\n org-limit-cap orgLimitCap CRUD operations\n membership-type membershipType CRUD operations\n migrate-file migrateFile CRUD operations\n devices-module devicesModule CRUD operations\n node-type-registry nodeTypeRegistry CRUD operations\n app-limit-default appLimitDefault CRUD operations\n org-limit-default orgLimitDefault CRUD operations\n user-connected-account userConnectedAccount CRUD operations\n commit commit CRUD operations\n pubkey-setting pubkeySetting CRUD operations\n rate-limits-module rateLimitsModule CRUD operations\n app-membership-default appMembershipDefault CRUD operations\n org-membership-default orgMembershipDefault CRUD operations\n rls-setting rlsSetting CRUD operations\n app-limit-event appLimitEvent CRUD operations\n org-limit-event orgLimitEvent CRUD operations\n rls-module rlsModule CRUD operations\n database-setting databaseSetting CRUD operations\n plans-module plansModule CRUD operations\n sql-action sqlAction CRUD operations\n billing-module billingModule CRUD operations\n ast-migration astMigration CRUD operations\n user user CRUD operations\n org-membership-setting orgMembershipSetting CRUD operations\n webauthn-setting webauthnSetting CRUD operations\n app-membership appMembership CRUD operations\n billing-provider-module billingProviderModule CRUD operations\n hierarchy-module hierarchyModule CRUD operations\n current-user-id currentUserId\n current-user-agent currentUserAgent\n current-ip-address currentIpAddress\n require-step-up requireStepUp\n app-permissions-get-padded-mask appPermissionsGetPaddedMask\n org-permissions-get-padded-mask orgPermissionsGetPaddedMask\n steps-achieved stepsAchieved\n rev-parse revParse\n resolve-blueprint-field Resolves a field_name within a given table_id to a field_id. Throws if no match is found. Used by construct_blueprint to translate user-authored field names (e.g. \"location\") into field UUIDs for downstream provisioning procedures. table_id must already be resolved (via resolve_blueprint_table) before calling this.\n org-is-manager-of orgIsManagerOf\n app-permissions-get-mask appPermissionsGetMask\n org-permissions-get-mask orgPermissionsGetMask\n resolve-blueprint-table Resolves a table_name (with optional schema_name) to a table_id. Resolution order: (1) if schema_name provided, exact lookup via metaschema_public.schema.name + metaschema_public.table; (2) check local table_map (tables created in current blueprint); (3) search metaschema_public.table by name across all schemas; (4) if multiple matches, throw ambiguous error asking for schema_name; (5) if no match, throw not-found error.\n app-permissions-get-mask-by-names appPermissionsGetMaskByNames\n org-permissions-get-mask-by-names orgPermissionsGetMaskByNames\n app-permissions-get-by-mask Reads and enables pagination through a set of `AppPermission`.\n org-permissions-get-by-mask Reads and enables pagination through a set of `OrgPermission`.\n get-all-objects-from-root Reads and enables pagination through a set of `Object`.\n get-path-objects-from-root Reads and enables pagination through a set of `Object`.\n get-object-at-path getObjectAtPath\n steps-required Reads and enables pagination through a set of `AppLevelRequirement`.\n current-user currentUser\n send-account-deletion-email sendAccountDeletionEmail\n sign-out signOut\n accept-database-transfer acceptDatabaseTransfer\n cancel-database-transfer cancelDatabaseTransfer\n reject-database-transfer rejectDatabaseTransfer\n disconnect-account disconnectAccount\n revoke-api-key revokeApiKey\n revoke-session revokeSession\n verify-password verifyPassword\n verify-totp verifyTotp\n submit-app-invite-code submitAppInviteCode\n submit-org-invite-code submitOrgInviteCode\n check-password checkPassword\n confirm-delete-account confirmDeleteAccount\n set-password setPassword\n verify-email verifyEmail\n freeze-objects freezeObjects\n init-empty-repo initEmptyRepo\n construct-blueprint Executes a blueprint definition by delegating to provision_* procedures. Creates a blueprint_construction record to track the attempt. Six phases: (0) entity_type_provision for each membership_type entry \u2014 provisions entity tables, membership modules, and security, (1) provision_table() for each table with nodes[], fields[], policies[], and grants (table-level indexes/fts/unique_constraints are deferred), (2) provision_relation() for each relation, (3) provision_index() for top-level + deferred indexes, (4) provision_full_text_search() for top-level + deferred FTS, (5) provision_unique_constraint() for top-level + deferred unique constraints. Phase 0 entity tables are added to the table_map so subsequent phases can reference them by name. Table-level indexes/fts/unique_constraints are deferred to phases 3-5 so they can reference columns created by relations in phase 2. Returns the construction record ID on success, NULL on failure.\n provision-new-user provisionNewUser\n reset-password resetPassword\n remove-node-at-path removeNodeAtPath\n copy-template-to-blueprint Creates a new blueprint by copying a template definition. Checks visibility: owners can always copy their own templates, others require public visibility. Increments the template copy_count. Returns the new blueprint ID.\n provision-spatial-relation Idempotent provisioner for metaschema_public.spatial_relation. Inserts a row declaring a spatial predicate between two geometry/geography columns (owner and target). Called from construct_blueprint when a relation entry has $type=RelationSpatial. Graceful: re-running with the same (source_table_id, name) returns the existing id without modifying the row. Operator whitelist and st_dwithin \u2194 param_name pairing are enforced by the spatial_relation table CHECKs. Both fields must already exist \u2014 this is a metadata-only insert.\n bootstrap-user bootstrapUser\n set-field-order setFieldOrder\n append-smart-tags appendSmartTags\n provision-unique-constraint Creates a unique constraint on a table. Accepts a jsonb definition with columns (array of field names). Graceful: skips if the exact same unique constraint already exists.\n provision-full-text-search Creates a full-text search configuration on a table. Accepts a jsonb definition with field (tsvector column name) and sources (array of {field, weight, lang}). Graceful: skips if FTS config already exists for the same (table_id, field_id). Returns the fts_id.\n provision-index Creates an index on a table. Accepts a jsonb definition with columns (array of names or single column string), access_method (default BTREE), is_unique, op_classes, options, and name (auto-generated if omitted). Graceful: skips if an index with the same (table_id, field_ids, access_method) already exists. Returns the index_id.\n set-data-at-path setDataAtPath\n set-props-and-commit setPropsAndCommit\n provision-database-with-user provisionDatabaseWithUser\n insert-node-at-path insertNodeAtPath\n update-node-at-path updateNodeAtPath\n set-and-commit setAndCommit\n provision-relation Composable relation provisioning: creates FK fields, indexes, unique constraints, and junction tables depending on the relation_type. Supports RelationBelongsTo, RelationHasOne, RelationHasMany, and RelationManyToMany. ManyToMany uses provision_table() internally for junction table creation with full node/grant/policy support. All operations are graceful (skip existing). Returns (out_field_id, out_junction_table_id, out_source_field_id, out_target_field_id).\n apply-rls applyRls\n sign-in-cross-origin signInCrossOrigin\n create-user-database Creates a new user database with all required modules, permissions, and RLS policies.\n\nParameters:\n - database_name: Name for the new database (required)\n - owner_id: UUID of the owner user (required)\n - include_invites: Include invite system (default: true)\n - include_groups: Include group-level memberships (default: false)\n - include_levels: Include levels/achievements (default: false)\n - bitlen: Bit length for permission masks (default: 64)\n - tokens_expiration: Token expiration interval (default: 30 days)\n\nReturns the database_id UUID of the newly created database.\n\nExample usage:\n SELECT metaschema_public.create_user_database('my_app', 'a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11'::uuid);\n SELECT metaschema_public.create_user_database('my_app', 'a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11'::uuid, true, true); -- with invites and groups\n\n extend-token-expires extendTokenExpires\n create-api-key createApiKey\n send-verification-email sendVerificationEmail\n forgot-password forgotPassword\n sign-up signUp\n request-cross-origin-token requestCrossOriginToken\n sign-in signIn\n provision-table Composable table provisioning: creates or finds a table, then creates fields (so Data* modules can reference them), applies N nodes (Data* modules), enables RLS, creates grants, creates N policies, and optionally creates table-level indexes/full_text_searches/unique_constraints. All operations are graceful (skip existing). Accepts multiple nodes and multiple policies per call, unlike secure_table_provision which is limited to one of each. Returns (out_table_id, out_fields).\n provision-bucket Provision an S3 bucket for a logical bucket in the database.\nReads the bucket config via RLS, then creates and configures\nthe S3 bucket with the appropriate privacy policies, CORS rules,\nand lifecycle settings.\n\n --help, -h Show this help message\n --version, -v Show version\n";
|
|
453
|
+
const usage = "\ncsdk <command>\n\nCommands:\n context Manage API contexts\n auth Manage authentication\n org-get-managers-record orgGetManagersRecord CRUD operations\n org-get-subordinates-record orgGetSubordinatesRecord CRUD operations\n get-all-record getAllRecord CRUD operations\n app-permission appPermission CRUD operations\n org-permission orgPermission CRUD operations\n object object CRUD operations\n app-level-requirement appLevelRequirement CRUD operations\n database database CRUD operations\n schema schema CRUD operations\n table table CRUD operations\n check-constraint checkConstraint CRUD operations\n field field CRUD operations\n spatial-relation spatialRelation CRUD operations\n partition partition CRUD operations\n foreign-key-constraint foreignKeyConstraint CRUD operations\n full-text-search fullTextSearch CRUD operations\n index index CRUD operations\n policy policy CRUD operations\n primary-key-constraint primaryKeyConstraint CRUD operations\n table-grant tableGrant CRUD operations\n trigger trigger CRUD operations\n unique-constraint uniqueConstraint CRUD operations\n view view CRUD operations\n view-table viewTable CRUD operations\n view-grant viewGrant CRUD operations\n view-rule viewRule CRUD operations\n embedding-chunk embeddingChunk CRUD operations\n secure-table-provision secureTableProvision CRUD operations\n relation-provision relationProvision CRUD operations\n session-secrets-module sessionSecretsModule CRUD operations\n identity-providers-module identityProvidersModule CRUD operations\n realtime-module realtimeModule CRUD operations\n schema-grant schemaGrant CRUD operations\n default-privilege defaultPrivilege CRUD operations\n enum enum CRUD operations\n function function CRUD operations\n api-schema apiSchema CRUD operations\n api-module apiModule CRUD operations\n domain domain CRUD operations\n site-metadatum siteMetadatum CRUD operations\n site-module siteModule CRUD operations\n site-theme siteTheme CRUD operations\n cors-setting corsSetting CRUD operations\n trigger-function triggerFunction CRUD operations\n database-transfer databaseTransfer CRUD operations\n api api CRUD operations\n site site CRUD operations\n app app CRUD operations\n api-setting apiSetting CRUD operations\n connected-accounts-module connectedAccountsModule CRUD operations\n crypto-addresses-module cryptoAddressesModule CRUD operations\n crypto-auth-module cryptoAuthModule CRUD operations\n default-ids-module defaultIdsModule CRUD operations\n denormalized-table-field denormalizedTableField CRUD operations\n emails-module emailsModule CRUD operations\n encrypted-secrets-module encryptedSecretsModule CRUD operations\n invites-module invitesModule CRUD operations\n levels-module levelsModule CRUD operations\n limits-module limitsModule CRUD operations\n membership-types-module membershipTypesModule CRUD operations\n memberships-module membershipsModule CRUD operations\n permissions-module permissionsModule CRUD operations\n phone-numbers-module phoneNumbersModule CRUD operations\n profiles-module profilesModule CRUD operations\n secrets-module secretsModule CRUD operations\n sessions-module sessionsModule CRUD operations\n user-auth-module userAuthModule CRUD operations\n users-module usersModule CRUD operations\n blueprint blueprint CRUD operations\n blueprint-template blueprintTemplate CRUD operations\n blueprint-construction blueprintConstruction CRUD operations\n storage-module storageModule CRUD operations\n entity-type-provision entityTypeProvision CRUD operations\n webauthn-credentials-module webauthnCredentialsModule CRUD operations\n webauthn-auth-module webauthnAuthModule CRUD operations\n notifications-module notificationsModule CRUD operations\n database-provision-module databaseProvisionModule CRUD operations\n app-admin-grant appAdminGrant CRUD operations\n app-owner-grant appOwnerGrant CRUD operations\n app-grant appGrant CRUD operations\n org-membership orgMembership CRUD operations\n org-member orgMember CRUD operations\n org-admin-grant orgAdminGrant CRUD operations\n org-owner-grant orgOwnerGrant CRUD operations\n org-member-profile orgMemberProfile CRUD operations\n org-grant orgGrant CRUD operations\n org-chart-edge orgChartEdge CRUD operations\n org-chart-edge-grant orgChartEdgeGrant CRUD operations\n org-permission-default orgPermissionDefault CRUD operations\n app-limit appLimit CRUD operations\n app-limit-credit appLimitCredit CRUD operations\n app-limit-credit-code-item appLimitCreditCodeItem CRUD operations\n app-limit-credit-redemption appLimitCreditRedemption CRUD operations\n org-limit orgLimit CRUD operations\n org-limit-credit orgLimitCredit CRUD operations\n org-limit-aggregate orgLimitAggregate CRUD operations\n app-step appStep CRUD operations\n app-achievement appAchievement CRUD operations\n app-level appLevel CRUD operations\n email email CRUD operations\n phone-number phoneNumber CRUD operations\n crypto-address cryptoAddress CRUD operations\n webauthn-credential webauthnCredential CRUD operations\n app-invite appInvite CRUD operations\n app-claimed-invite appClaimedInvite CRUD operations\n org-invite orgInvite CRUD operations\n org-claimed-invite orgClaimedInvite CRUD operations\n audit-log auditLog CRUD operations\n agent-thread agentThread CRUD operations\n agent-message agentMessage CRUD operations\n agent-task agentTask CRUD operations\n role-type roleType CRUD operations\n identity-provider identityProvider CRUD operations\n ref ref CRUD operations\n store store CRUD operations\n app-permission-default appPermissionDefault CRUD operations\n app-limit-credit-code appLimitCreditCode CRUD operations\n app-limit-caps-default appLimitCapsDefault CRUD operations\n org-limit-caps-default orgLimitCapsDefault CRUD operations\n app-limit-cap appLimitCap CRUD operations\n org-limit-cap orgLimitCap CRUD operations\n membership-type membershipType CRUD operations\n migrate-file migrateFile CRUD operations\n devices-module devicesModule CRUD operations\n node-type-registry nodeTypeRegistry CRUD operations\n app-limit-default appLimitDefault CRUD operations\n org-limit-default orgLimitDefault CRUD operations\n user-connected-account userConnectedAccount CRUD operations\n commit commit CRUD operations\n pubkey-setting pubkeySetting CRUD operations\n rate-limits-module rateLimitsModule CRUD operations\n app-membership-default appMembershipDefault CRUD operations\n org-membership-default orgMembershipDefault CRUD operations\n rls-setting rlsSetting CRUD operations\n app-limit-event appLimitEvent CRUD operations\n org-limit-event orgLimitEvent CRUD operations\n rls-module rlsModule CRUD operations\n database-setting databaseSetting CRUD operations\n plans-module plansModule CRUD operations\n sql-action sqlAction CRUD operations\n billing-module billingModule CRUD operations\n ast-migration astMigration CRUD operations\n user user CRUD operations\n org-membership-setting orgMembershipSetting CRUD operations\n webauthn-setting webauthnSetting CRUD operations\n app-membership appMembership CRUD operations\n billing-provider-module billingProviderModule CRUD operations\n hierarchy-module hierarchyModule CRUD operations\n current-user-id currentUserId\n current-user-agent currentUserAgent\n current-ip-address currentIpAddress\n require-step-up requireStepUp\n app-permissions-get-padded-mask appPermissionsGetPaddedMask\n org-permissions-get-padded-mask orgPermissionsGetPaddedMask\n steps-achieved stepsAchieved\n rev-parse revParse\n resolve-blueprint-field Resolves a field_name within a given table_id to a field_id. Throws if no match is found. Used by construct_blueprint to translate user-authored field names (e.g. \"location\") into field UUIDs for downstream provisioning procedures. table_id must already be resolved (via resolve_blueprint_table) before calling this.\n org-is-manager-of orgIsManagerOf\n app-permissions-get-mask appPermissionsGetMask\n org-permissions-get-mask orgPermissionsGetMask\n resolve-blueprint-table Resolves a table_name (with optional schema_name) to a table_id. Resolution order: (1) if schema_name provided, exact lookup via metaschema_public.schema.name + metaschema_public.table; (2) check local table_map (tables created in current blueprint); (3) search metaschema_public.table by name across all schemas; (4) if multiple matches, throw ambiguous error asking for schema_name; (5) if no match, throw not-found error.\n app-permissions-get-mask-by-names appPermissionsGetMaskByNames\n org-permissions-get-mask-by-names orgPermissionsGetMaskByNames\n app-permissions-get-by-mask Reads and enables pagination through a set of `AppPermission`.\n org-permissions-get-by-mask Reads and enables pagination through a set of `OrgPermission`.\n get-all-objects-from-root Reads and enables pagination through a set of `Object`.\n get-path-objects-from-root Reads and enables pagination through a set of `Object`.\n get-object-at-path getObjectAtPath\n steps-required Reads and enables pagination through a set of `AppLevelRequirement`.\n current-user currentUser\n send-account-deletion-email sendAccountDeletionEmail\n sign-out signOut\n accept-database-transfer acceptDatabaseTransfer\n cancel-database-transfer cancelDatabaseTransfer\n reject-database-transfer rejectDatabaseTransfer\n disconnect-account disconnectAccount\n revoke-api-key revokeApiKey\n revoke-session revokeSession\n verify-password verifyPassword\n verify-totp verifyTotp\n submit-app-invite-code submitAppInviteCode\n submit-org-invite-code submitOrgInviteCode\n check-password checkPassword\n confirm-delete-account confirmDeleteAccount\n set-password setPassword\n verify-email verifyEmail\n freeze-objects freezeObjects\n init-empty-repo initEmptyRepo\n construct-blueprint Executes a blueprint definition by delegating to provision_* procedures. Creates a blueprint_construction record to track the attempt. Six phases: (0) entity_type_provision for each membership_type entry \u2014 provisions entity tables, membership modules, and security, (1) provision_table() for each table with nodes[], fields[], policies[], and grants (table-level indexes/fts/unique_constraints are deferred), (2) provision_relation() for each relation, (3) provision_index() for top-level + deferred indexes, (4) provision_full_text_search() for top-level + deferred FTS, (5) provision_unique_constraint() for top-level + deferred unique constraints. Phase 0 entity tables are added to the table_map so subsequent phases can reference them by name. Table-level indexes/fts/unique_constraints are deferred to phases 3-5 so they can reference columns created by relations in phase 2. Returns the construction record ID on success, NULL on failure.\n provision-new-user provisionNewUser\n reset-password resetPassword\n remove-node-at-path removeNodeAtPath\n copy-template-to-blueprint Creates a new blueprint by copying a template definition. Checks visibility: owners can always copy their own templates, others require public visibility. Increments the template copy_count. Returns the new blueprint ID.\n provision-spatial-relation Idempotent provisioner for metaschema_public.spatial_relation. Inserts a row declaring a spatial predicate between two geometry/geography columns (owner and target). Called from construct_blueprint when a relation entry has $type=RelationSpatial. Graceful: re-running with the same (source_table_id, name) returns the existing id without modifying the row. Operator whitelist and st_dwithin \u2194 param_name pairing are enforced by the spatial_relation table CHECKs. Both fields must already exist \u2014 this is a metadata-only insert.\n bootstrap-user bootstrapUser\n set-field-order setFieldOrder\n append-field-smart-tags appendFieldSmartTags\n append-table-smart-tags appendTableSmartTags\n provision-unique-constraint Creates a unique constraint on a table. Accepts a jsonb definition with columns (array of field names). Graceful: skips if the exact same unique constraint already exists.\n provision-full-text-search Creates a full-text search configuration on a table. Accepts a jsonb definition with field (tsvector column name) and sources (array of {field, weight, lang}). Graceful: skips if FTS config already exists for the same (table_id, field_id). Returns the fts_id.\n provision-index Creates an index on a table. Accepts a jsonb definition with columns (array of names or single column string), access_method (default BTREE), is_unique, op_classes, options, and name (auto-generated if omitted). Graceful: skips if an index with the same (table_id, field_ids, access_method) already exists. Returns the index_id.\n set-data-at-path setDataAtPath\n set-props-and-commit setPropsAndCommit\n provision-database-with-user provisionDatabaseWithUser\n insert-node-at-path insertNodeAtPath\n update-node-at-path updateNodeAtPath\n set-and-commit setAndCommit\n provision-relation Composable relation provisioning: creates FK fields, indexes, unique constraints, and junction tables depending on the relation_type. Supports RelationBelongsTo, RelationHasOne, RelationHasMany, and RelationManyToMany. ManyToMany uses provision_table() internally for junction table creation with full node/grant/policy support. All operations are graceful (skip existing). Returns (out_field_id, out_junction_table_id, out_source_field_id, out_target_field_id).\n apply-rls applyRls\n sign-in-cross-origin signInCrossOrigin\n create-user-database Creates a new user database with all required modules, permissions, and RLS policies.\n\nParameters:\n - database_name: Name for the new database (required)\n - owner_id: UUID of the owner user (required)\n - include_invites: Include invite system (default: true)\n - include_groups: Include group-level memberships (default: false)\n - include_levels: Include levels/achievements (default: false)\n - bitlen: Bit length for permission masks (default: 64)\n - tokens_expiration: Token expiration interval (default: 30 days)\n\nReturns the database_id UUID of the newly created database.\n\nExample usage:\n SELECT metaschema_public.create_user_database('my_app', 'a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11'::uuid);\n SELECT metaschema_public.create_user_database('my_app', 'a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11'::uuid, true, true); -- with invites and groups\n\n extend-token-expires extendTokenExpires\n create-api-key createApiKey\n send-verification-email sendVerificationEmail\n forgot-password forgotPassword\n sign-up signUp\n request-cross-origin-token requestCrossOriginToken\n sign-in signIn\n provision-table Composable table provisioning: creates or finds a table, then creates fields (so Data* modules can reference them), applies N nodes (Data* modules), enables RLS, creates grants, creates N policies, and optionally creates table-level indexes/full_text_searches/unique_constraints. All operations are graceful (skip existing). Accepts multiple nodes and multiple policies per call, unlike secure_table_provision which is limited to one of each. Returns (out_table_id, out_fields).\n provision-bucket Provision an S3 bucket for a logical bucket in the database.\nReads the bucket config via RLS, then creates and configures\nthe S3 bucket with the appropriate privacy policies, CORS rules,\nand lifecycle settings.\n\n --help, -h Show this help message\n --version, -v Show version\n";
|
|
452
454
|
export const commands = async (argv, prompter, options) => {
|
|
453
455
|
if (argv.help || argv.h) {
|
|
454
456
|
console.log(usage);
|
|
@@ -391,10 +391,15 @@ export declare function getClient(contextName?: string): {
|
|
|
391
391
|
} & import("..").StrictSelect<S, import("../orm/input-types").SetFieldOrderPayloadSelect>) => import("..").QueryBuilder<{
|
|
392
392
|
setFieldOrder: import("..").InferSelectResult<import("../orm/input-types").SetFieldOrderPayload, S> | null;
|
|
393
393
|
}>;
|
|
394
|
-
|
|
394
|
+
appendFieldSmartTags: <S extends import("../orm/input-types").AppendFieldSmartTagsPayloadSelect>(args: import("../orm/mutation").AppendFieldSmartTagsVariables, options: {
|
|
395
395
|
select: S;
|
|
396
|
-
} & import("..").StrictSelect<S, import("../orm/input-types").
|
|
397
|
-
|
|
396
|
+
} & import("..").StrictSelect<S, import("../orm/input-types").AppendFieldSmartTagsPayloadSelect>) => import("..").QueryBuilder<{
|
|
397
|
+
appendFieldSmartTags: import("..").InferSelectResult<import("../orm/input-types").AppendFieldSmartTagsPayload, S> | null;
|
|
398
|
+
}>;
|
|
399
|
+
appendTableSmartTags: <S extends import("../orm/input-types").AppendTableSmartTagsPayloadSelect>(args: import("../orm/mutation").AppendTableSmartTagsVariables, options: {
|
|
400
|
+
select: S;
|
|
401
|
+
} & import("..").StrictSelect<S, import("../orm/input-types").AppendTableSmartTagsPayloadSelect>) => import("..").QueryBuilder<{
|
|
402
|
+
appendTableSmartTags: import("..").InferSelectResult<import("../orm/input-types").AppendTableSmartTagsPayload, S> | null;
|
|
398
403
|
}>;
|
|
399
404
|
provisionUniqueConstraint: <S extends import("../orm/input-types").ProvisionUniqueConstraintPayloadSelect>(args: import("../orm/mutation").ProvisionUniqueConstraintVariables, options: {
|
|
400
405
|
select: S;
|
|
@@ -4,7 +4,10 @@
|
|
|
4
4
|
* DO NOT EDIT - changes will be overwritten
|
|
5
5
|
*/
|
|
6
6
|
import type { GraphQLAdapter, GraphQLError, QueryResult } from '@constructive-io/graphql-query/runtime';
|
|
7
|
+
import type { ConnectionState, ConnectionStateListener, RealtimeConfig, SubscriptionEvent, SubscriptionFieldMeta, Unsubscribe } from './realtime';
|
|
7
8
|
export type { GraphQLAdapter, GraphQLError, QueryResult, } from '@constructive-io/graphql-query/runtime';
|
|
9
|
+
export type { ConnectionState, ConnectionStateListener, RealtimeConfig, SubscribeOptions, SubscriptionEvent, SubscriptionFieldMeta, SubscriptionOperation, Unsubscribe, WsClient, } from './realtime';
|
|
10
|
+
export { RealtimeManager } from './realtime';
|
|
8
11
|
/**
|
|
9
12
|
* Default adapter that uses fetch for HTTP requests.
|
|
10
13
|
*
|
|
@@ -41,6 +44,12 @@ export interface OrmClientConfig {
|
|
|
41
44
|
fetch?: typeof globalThis.fetch;
|
|
42
45
|
/** Custom adapter for GraphQL execution (overrides endpoint/headers/fetch) */
|
|
43
46
|
adapter?: GraphQLAdapter;
|
|
47
|
+
/**
|
|
48
|
+
* Optional realtime (WebSocket) configuration.
|
|
49
|
+
* When provided, enables subscription methods on models.
|
|
50
|
+
* The WebSocket connection is created lazily on first subscribe().
|
|
51
|
+
*/
|
|
52
|
+
realtime?: RealtimeConfig;
|
|
44
53
|
}
|
|
45
54
|
/**
|
|
46
55
|
* Error thrown when GraphQL request fails
|
|
@@ -52,8 +61,19 @@ export declare class GraphQLRequestError extends Error {
|
|
|
52
61
|
}
|
|
53
62
|
export declare class OrmClient {
|
|
54
63
|
private adapter;
|
|
64
|
+
private realtimeManager?;
|
|
55
65
|
constructor(config: OrmClientConfig);
|
|
56
66
|
execute<T>(document: string, variables?: Record<string, unknown>): Promise<QueryResult<T>>;
|
|
67
|
+
/**
|
|
68
|
+
* Subscribe to a GraphQL subscription operation.
|
|
69
|
+
* Used by generated model subscribe() methods.
|
|
70
|
+
* @throws Error if realtime is not configured
|
|
71
|
+
*/
|
|
72
|
+
subscribe<T>(meta: SubscriptionFieldMeta, document: string, variables: Record<string, unknown>, options: {
|
|
73
|
+
onEvent: (event: SubscriptionEvent<T>) => void;
|
|
74
|
+
onError?: (error: Error) => void;
|
|
75
|
+
onComplete?: () => void;
|
|
76
|
+
}): Unsubscribe;
|
|
57
77
|
/**
|
|
58
78
|
* Set headers for requests.
|
|
59
79
|
* Only works if the adapter supports headers.
|
|
@@ -64,4 +84,14 @@ export declare class OrmClient {
|
|
|
64
84
|
* Returns empty string if the adapter doesn't have an endpoint.
|
|
65
85
|
*/
|
|
66
86
|
getEndpoint(): string;
|
|
87
|
+
/** Get current WebSocket connection state */
|
|
88
|
+
getConnectionState(): ConnectionState;
|
|
89
|
+
/** Register a listener for WebSocket connection state changes */
|
|
90
|
+
onConnectionStateChange(listener: ConnectionStateListener): Unsubscribe;
|
|
91
|
+
/** Number of active subscriptions */
|
|
92
|
+
getActiveSubscriptionCount(): number;
|
|
93
|
+
/** Whether realtime is configured */
|
|
94
|
+
get isRealtimeEnabled(): boolean;
|
|
95
|
+
/** Dispose the realtime manager (close WebSocket) */
|
|
96
|
+
dispose(): void;
|
|
67
97
|
}
|
package/esm/public/orm/client.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { createFetch } from '@constructive-io/graphql-query/runtime';
|
|
2
|
+
import { RealtimeManager } from './realtime';
|
|
3
|
+
export { RealtimeManager } from './realtime';
|
|
2
4
|
/**
|
|
3
5
|
* Default adapter that uses fetch for HTTP requests.
|
|
4
6
|
*
|
|
@@ -73,6 +75,7 @@ export class GraphQLRequestError extends Error {
|
|
|
73
75
|
}
|
|
74
76
|
export class OrmClient {
|
|
75
77
|
adapter;
|
|
78
|
+
realtimeManager;
|
|
76
79
|
constructor(config) {
|
|
77
80
|
if (config.adapter) {
|
|
78
81
|
this.adapter = config.adapter;
|
|
@@ -83,10 +86,24 @@ export class OrmClient {
|
|
|
83
86
|
else {
|
|
84
87
|
throw new Error('OrmClientConfig requires either an endpoint or a custom adapter');
|
|
85
88
|
}
|
|
89
|
+
if (config.realtime) {
|
|
90
|
+
this.realtimeManager = new RealtimeManager(config.realtime);
|
|
91
|
+
}
|
|
86
92
|
}
|
|
87
93
|
async execute(document, variables) {
|
|
88
94
|
return this.adapter.execute(document, variables);
|
|
89
95
|
}
|
|
96
|
+
/**
|
|
97
|
+
* Subscribe to a GraphQL subscription operation.
|
|
98
|
+
* Used by generated model subscribe() methods.
|
|
99
|
+
* @throws Error if realtime is not configured
|
|
100
|
+
*/
|
|
101
|
+
subscribe(meta, document, variables, options) {
|
|
102
|
+
if (!this.realtimeManager) {
|
|
103
|
+
throw new Error('Realtime not configured. Pass a `realtime` option to createClient() to enable subscriptions.');
|
|
104
|
+
}
|
|
105
|
+
return this.realtimeManager.subscribe(meta, document, variables, options);
|
|
106
|
+
}
|
|
90
107
|
/**
|
|
91
108
|
* Set headers for requests.
|
|
92
109
|
* Only works if the adapter supports headers.
|
|
@@ -103,4 +120,26 @@ export class OrmClient {
|
|
|
103
120
|
getEndpoint() {
|
|
104
121
|
return this.adapter.getEndpoint?.() ?? '';
|
|
105
122
|
}
|
|
123
|
+
/** Get current WebSocket connection state */
|
|
124
|
+
getConnectionState() {
|
|
125
|
+
return this.realtimeManager?.getConnectionState() ?? 'disconnected';
|
|
126
|
+
}
|
|
127
|
+
/** Register a listener for WebSocket connection state changes */
|
|
128
|
+
onConnectionStateChange(listener) {
|
|
129
|
+
if (!this.realtimeManager)
|
|
130
|
+
return () => { };
|
|
131
|
+
return this.realtimeManager.onConnectionStateChange(listener);
|
|
132
|
+
}
|
|
133
|
+
/** Number of active subscriptions */
|
|
134
|
+
getActiveSubscriptionCount() {
|
|
135
|
+
return this.realtimeManager?.getActiveSubscriptionCount() ?? 0;
|
|
136
|
+
}
|
|
137
|
+
/** Whether realtime is configured */
|
|
138
|
+
get isRealtimeEnabled() {
|
|
139
|
+
return this.realtimeManager !== undefined;
|
|
140
|
+
}
|
|
141
|
+
/** Dispose the realtime manager (close WebSocket) */
|
|
142
|
+
dispose() {
|
|
143
|
+
this.realtimeManager?.dispose();
|
|
144
|
+
}
|
|
106
145
|
}
|
|
@@ -570,10 +570,15 @@ export declare function createClient(config: OrmClientConfig): {
|
|
|
570
570
|
} & import("./select-types").StrictSelect<S, import("./input-types").SetFieldOrderPayloadSelect>) => import("./query-builder").QueryBuilder<{
|
|
571
571
|
setFieldOrder: import("./select-types").InferSelectResult<import("./input-types").SetFieldOrderPayload, S> | null;
|
|
572
572
|
}>;
|
|
573
|
-
|
|
573
|
+
appendFieldSmartTags: <S extends import("./input-types").AppendFieldSmartTagsPayloadSelect>(args: import("./mutation").AppendFieldSmartTagsVariables, options: {
|
|
574
574
|
select: S;
|
|
575
|
-
} & import("./select-types").StrictSelect<S, import("./input-types").
|
|
576
|
-
|
|
575
|
+
} & import("./select-types").StrictSelect<S, import("./input-types").AppendFieldSmartTagsPayloadSelect>) => import("./query-builder").QueryBuilder<{
|
|
576
|
+
appendFieldSmartTags: import("./select-types").InferSelectResult<import("./input-types").AppendFieldSmartTagsPayload, S> | null;
|
|
577
|
+
}>;
|
|
578
|
+
appendTableSmartTags: <S extends import("./input-types").AppendTableSmartTagsPayloadSelect>(args: import("./mutation").AppendTableSmartTagsVariables, options: {
|
|
579
|
+
select: S;
|
|
580
|
+
} & import("./select-types").StrictSelect<S, import("./input-types").AppendTableSmartTagsPayloadSelect>) => import("./query-builder").QueryBuilder<{
|
|
581
|
+
appendTableSmartTags: import("./select-types").InferSelectResult<import("./input-types").AppendTableSmartTagsPayload, S> | null;
|
|
577
582
|
}>;
|
|
578
583
|
provisionUniqueConstraint: <S extends import("./input-types").ProvisionUniqueConstraintPayloadSelect>(args: import("./mutation").ProvisionUniqueConstraintVariables, options: {
|
|
579
584
|
select: S;
|
|
@@ -19201,7 +19201,12 @@ export interface SetFieldOrderInput {
|
|
|
19201
19201
|
clientMutationId?: string;
|
|
19202
19202
|
fieldIds?: string[];
|
|
19203
19203
|
}
|
|
19204
|
-
export interface
|
|
19204
|
+
export interface AppendFieldSmartTagsInput {
|
|
19205
|
+
clientMutationId?: string;
|
|
19206
|
+
pFieldId?: string;
|
|
19207
|
+
pTags?: Record<string, unknown>;
|
|
19208
|
+
}
|
|
19209
|
+
export interface AppendTableSmartTagsInput {
|
|
19205
19210
|
clientMutationId?: string;
|
|
19206
19211
|
pTableId?: string;
|
|
19207
19212
|
pTags?: Record<string, unknown>;
|
|
@@ -27717,10 +27722,16 @@ export interface SetFieldOrderPayload {
|
|
|
27717
27722
|
export type SetFieldOrderPayloadSelect = {
|
|
27718
27723
|
clientMutationId?: boolean;
|
|
27719
27724
|
};
|
|
27720
|
-
export interface
|
|
27725
|
+
export interface AppendFieldSmartTagsPayload {
|
|
27726
|
+
clientMutationId?: string | null;
|
|
27727
|
+
}
|
|
27728
|
+
export type AppendFieldSmartTagsPayloadSelect = {
|
|
27729
|
+
clientMutationId?: boolean;
|
|
27730
|
+
};
|
|
27731
|
+
export interface AppendTableSmartTagsPayload {
|
|
27721
27732
|
clientMutationId?: string | null;
|
|
27722
27733
|
}
|
|
27723
|
-
export type
|
|
27734
|
+
export type AppendTableSmartTagsPayloadSelect = {
|
|
27724
27735
|
clientMutationId?: boolean;
|
|
27725
27736
|
};
|
|
27726
27737
|
export interface ProvisionUniqueConstraintPayload {
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
import { OrmClient } from '../client';
|
|
7
7
|
import { QueryBuilder } from '../query-builder';
|
|
8
8
|
import type { InferSelectResult, StrictSelect } from '../select-types';
|
|
9
|
-
import type { SendAccountDeletionEmailInput, SignOutInput, AcceptDatabaseTransferInput, CancelDatabaseTransferInput, RejectDatabaseTransferInput, DisconnectAccountInput, RevokeApiKeyInput, RevokeSessionInput, VerifyPasswordInput, VerifyTotpInput, SubmitAppInviteCodeInput, SubmitOrgInviteCodeInput, CheckPasswordInput, ConfirmDeleteAccountInput, SetPasswordInput, VerifyEmailInput, FreezeObjectsInput, InitEmptyRepoInput, ConstructBlueprintInput, ProvisionNewUserInput, ResetPasswordInput, RemoveNodeAtPathInput, CopyTemplateToBlueprintInput, ProvisionSpatialRelationInput, BootstrapUserInput, SetFieldOrderInput,
|
|
9
|
+
import type { SendAccountDeletionEmailInput, SignOutInput, AcceptDatabaseTransferInput, CancelDatabaseTransferInput, RejectDatabaseTransferInput, DisconnectAccountInput, RevokeApiKeyInput, RevokeSessionInput, VerifyPasswordInput, VerifyTotpInput, SubmitAppInviteCodeInput, SubmitOrgInviteCodeInput, CheckPasswordInput, ConfirmDeleteAccountInput, SetPasswordInput, VerifyEmailInput, FreezeObjectsInput, InitEmptyRepoInput, ConstructBlueprintInput, ProvisionNewUserInput, ResetPasswordInput, RemoveNodeAtPathInput, CopyTemplateToBlueprintInput, ProvisionSpatialRelationInput, BootstrapUserInput, SetFieldOrderInput, AppendFieldSmartTagsInput, AppendTableSmartTagsInput, ProvisionUniqueConstraintInput, ProvisionFullTextSearchInput, ProvisionIndexInput, SetDataAtPathInput, SetPropsAndCommitInput, ProvisionDatabaseWithUserInput, InsertNodeAtPathInput, UpdateNodeAtPathInput, SetAndCommitInput, ProvisionRelationInput, ApplyRlsInput, SignInCrossOriginInput, CreateUserDatabaseInput, ExtendTokenExpiresInput, CreateApiKeyInput, SendVerificationEmailInput, ForgotPasswordInput, SignUpInput, RequestCrossOriginTokenInput, SignInInput, ProvisionTableInput, ProvisionBucketInput, SendAccountDeletionEmailPayload, SignOutPayload, AcceptDatabaseTransferPayload, CancelDatabaseTransferPayload, RejectDatabaseTransferPayload, DisconnectAccountPayload, RevokeApiKeyPayload, RevokeSessionPayload, VerifyPasswordPayload, VerifyTotpPayload, SubmitAppInviteCodePayload, SubmitOrgInviteCodePayload, CheckPasswordPayload, ConfirmDeleteAccountPayload, SetPasswordPayload, VerifyEmailPayload, FreezeObjectsPayload, InitEmptyRepoPayload, ConstructBlueprintPayload, ProvisionNewUserPayload, ResetPasswordPayload, RemoveNodeAtPathPayload, CopyTemplateToBlueprintPayload, ProvisionSpatialRelationPayload, BootstrapUserPayload, SetFieldOrderPayload, AppendFieldSmartTagsPayload, AppendTableSmartTagsPayload, ProvisionUniqueConstraintPayload, ProvisionFullTextSearchPayload, ProvisionIndexPayload, SetDataAtPathPayload, SetPropsAndCommitPayload, ProvisionDatabaseWithUserPayload, InsertNodeAtPathPayload, UpdateNodeAtPathPayload, SetAndCommitPayload, ProvisionRelationPayload, ApplyRlsPayload, SignInCrossOriginPayload, CreateUserDatabasePayload, ExtendTokenExpiresPayload, CreateApiKeyPayload, SendVerificationEmailPayload, ForgotPasswordPayload, SignUpPayload, RequestCrossOriginTokenPayload, SignInPayload, ProvisionTablePayload, ProvisionBucketPayload, SendAccountDeletionEmailPayloadSelect, SignOutPayloadSelect, AcceptDatabaseTransferPayloadSelect, CancelDatabaseTransferPayloadSelect, RejectDatabaseTransferPayloadSelect, DisconnectAccountPayloadSelect, RevokeApiKeyPayloadSelect, RevokeSessionPayloadSelect, VerifyPasswordPayloadSelect, VerifyTotpPayloadSelect, SubmitAppInviteCodePayloadSelect, SubmitOrgInviteCodePayloadSelect, CheckPasswordPayloadSelect, ConfirmDeleteAccountPayloadSelect, SetPasswordPayloadSelect, VerifyEmailPayloadSelect, FreezeObjectsPayloadSelect, InitEmptyRepoPayloadSelect, ConstructBlueprintPayloadSelect, ProvisionNewUserPayloadSelect, ResetPasswordPayloadSelect, RemoveNodeAtPathPayloadSelect, CopyTemplateToBlueprintPayloadSelect, ProvisionSpatialRelationPayloadSelect, BootstrapUserPayloadSelect, SetFieldOrderPayloadSelect, AppendFieldSmartTagsPayloadSelect, AppendTableSmartTagsPayloadSelect, ProvisionUniqueConstraintPayloadSelect, ProvisionFullTextSearchPayloadSelect, ProvisionIndexPayloadSelect, SetDataAtPathPayloadSelect, SetPropsAndCommitPayloadSelect, ProvisionDatabaseWithUserPayloadSelect, InsertNodeAtPathPayloadSelect, UpdateNodeAtPathPayloadSelect, SetAndCommitPayloadSelect, ProvisionRelationPayloadSelect, ApplyRlsPayloadSelect, SignInCrossOriginPayloadSelect, CreateUserDatabasePayloadSelect, ExtendTokenExpiresPayloadSelect, CreateApiKeyPayloadSelect, SendVerificationEmailPayloadSelect, ForgotPasswordPayloadSelect, SignUpPayloadSelect, RequestCrossOriginTokenPayloadSelect, SignInPayloadSelect, ProvisionTablePayloadSelect, ProvisionBucketPayloadSelect } from '../input-types';
|
|
10
10
|
export interface SendAccountDeletionEmailVariables {
|
|
11
11
|
input: SendAccountDeletionEmailInput;
|
|
12
12
|
}
|
|
@@ -97,8 +97,11 @@ export interface BootstrapUserVariables {
|
|
|
97
97
|
export interface SetFieldOrderVariables {
|
|
98
98
|
input: SetFieldOrderInput;
|
|
99
99
|
}
|
|
100
|
-
export interface
|
|
101
|
-
input:
|
|
100
|
+
export interface AppendFieldSmartTagsVariables {
|
|
101
|
+
input: AppendFieldSmartTagsInput;
|
|
102
|
+
}
|
|
103
|
+
export interface AppendTableSmartTagsVariables {
|
|
104
|
+
input: AppendTableSmartTagsInput;
|
|
102
105
|
}
|
|
103
106
|
/**
|
|
104
107
|
* Variables for provisionUniqueConstraint
|
|
@@ -343,10 +346,15 @@ export declare function createMutationOperations(client: OrmClient): {
|
|
|
343
346
|
} & StrictSelect<S, SetFieldOrderPayloadSelect>) => QueryBuilder<{
|
|
344
347
|
setFieldOrder: InferSelectResult<SetFieldOrderPayload, S> | null;
|
|
345
348
|
}>;
|
|
346
|
-
|
|
349
|
+
appendFieldSmartTags: <S extends AppendFieldSmartTagsPayloadSelect>(args: AppendFieldSmartTagsVariables, options: {
|
|
350
|
+
select: S;
|
|
351
|
+
} & StrictSelect<S, AppendFieldSmartTagsPayloadSelect>) => QueryBuilder<{
|
|
352
|
+
appendFieldSmartTags: InferSelectResult<AppendFieldSmartTagsPayload, S> | null;
|
|
353
|
+
}>;
|
|
354
|
+
appendTableSmartTags: <S extends AppendTableSmartTagsPayloadSelect>(args: AppendTableSmartTagsVariables, options: {
|
|
347
355
|
select: S;
|
|
348
|
-
} & StrictSelect<S,
|
|
349
|
-
|
|
356
|
+
} & StrictSelect<S, AppendTableSmartTagsPayloadSelect>) => QueryBuilder<{
|
|
357
|
+
appendTableSmartTags: InferSelectResult<AppendTableSmartTagsPayload, S> | null;
|
|
350
358
|
}>;
|
|
351
359
|
provisionUniqueConstraint: <S extends ProvisionUniqueConstraintPayloadSelect>(args: ProvisionUniqueConstraintVariables, options: {
|
|
352
360
|
select: S;
|
|
@@ -314,17 +314,29 @@ export function createMutationOperations(client) {
|
|
|
314
314
|
},
|
|
315
315
|
], connectionFieldsMap, 'SetFieldOrderPayload'),
|
|
316
316
|
}),
|
|
317
|
-
|
|
317
|
+
appendFieldSmartTags: (args, options) => new QueryBuilder({
|
|
318
318
|
client,
|
|
319
319
|
operation: 'mutation',
|
|
320
|
-
operationName: '
|
|
321
|
-
fieldName: '
|
|
322
|
-
...buildCustomDocument('mutation', '
|
|
320
|
+
operationName: 'AppendFieldSmartTags',
|
|
321
|
+
fieldName: 'appendFieldSmartTags',
|
|
322
|
+
...buildCustomDocument('mutation', 'AppendFieldSmartTags', 'appendFieldSmartTags', options.select, args, [
|
|
323
323
|
{
|
|
324
324
|
name: 'input',
|
|
325
|
-
type: '
|
|
325
|
+
type: 'AppendFieldSmartTagsInput!',
|
|
326
326
|
},
|
|
327
|
-
], connectionFieldsMap, '
|
|
327
|
+
], connectionFieldsMap, 'AppendFieldSmartTagsPayload'),
|
|
328
|
+
}),
|
|
329
|
+
appendTableSmartTags: (args, options) => new QueryBuilder({
|
|
330
|
+
client,
|
|
331
|
+
operation: 'mutation',
|
|
332
|
+
operationName: 'AppendTableSmartTags',
|
|
333
|
+
fieldName: 'appendTableSmartTags',
|
|
334
|
+
...buildCustomDocument('mutation', 'AppendTableSmartTags', 'appendTableSmartTags', options.select, args, [
|
|
335
|
+
{
|
|
336
|
+
name: 'input',
|
|
337
|
+
type: 'AppendTableSmartTagsInput!',
|
|
338
|
+
},
|
|
339
|
+
], connectionFieldsMap, 'AppendTableSmartTagsPayload'),
|
|
328
340
|
}),
|
|
329
341
|
provisionUniqueConstraint: (args, options) => new QueryBuilder({
|
|
330
342
|
client,
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Realtime Manager - WebSocket subscription support
|
|
3
|
+
* @generated by @constructive-io/graphql-codegen
|
|
4
|
+
* DO NOT EDIT - changes will be overwritten
|
|
5
|
+
*/
|
|
6
|
+
interface WsGraphQLError {
|
|
7
|
+
readonly message: string;
|
|
8
|
+
readonly [key: string]: unknown;
|
|
9
|
+
}
|
|
10
|
+
interface WsExecutionResult<TData = Record<string, unknown>> {
|
|
11
|
+
data?: TData | null;
|
|
12
|
+
errors?: readonly WsGraphQLError[];
|
|
13
|
+
extensions?: Record<string, unknown>;
|
|
14
|
+
}
|
|
15
|
+
interface WsSink<T> {
|
|
16
|
+
next(value: T): void;
|
|
17
|
+
error(error: unknown): void;
|
|
18
|
+
complete(): void;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Minimal interface matching the graphql-ws Client.
|
|
22
|
+
* Consumers pass a concrete instance via RealtimeConfig.client.
|
|
23
|
+
*/
|
|
24
|
+
export interface WsClient {
|
|
25
|
+
subscribe<TData = Record<string, unknown>>(payload: {
|
|
26
|
+
query: string;
|
|
27
|
+
variables?: Record<string, unknown>;
|
|
28
|
+
}, sink: WsSink<WsExecutionResult<TData>>): () => void;
|
|
29
|
+
dispose(): void;
|
|
30
|
+
}
|
|
31
|
+
/** The DML operation that triggered the subscription event */
|
|
32
|
+
export type SubscriptionOperation = 'INSERT' | 'UPDATE' | 'DELETE';
|
|
33
|
+
/** Connection state of the WebSocket */
|
|
34
|
+
export type ConnectionState = 'disconnected' | 'connecting' | 'connected' | 'reconnecting';
|
|
35
|
+
/** Listener for connection state changes */
|
|
36
|
+
export type ConnectionStateListener = (state: ConnectionState) => void;
|
|
37
|
+
/** Function returned by subscribe() to cancel the subscription */
|
|
38
|
+
export type Unsubscribe = () => void;
|
|
39
|
+
/**
|
|
40
|
+
* A realtime subscription event delivered to the client.
|
|
41
|
+
*
|
|
42
|
+
* @typeParam T - The row type of the subscribed table
|
|
43
|
+
*/
|
|
44
|
+
export interface SubscriptionEvent<T> {
|
|
45
|
+
/** The DML operation that triggered this event */
|
|
46
|
+
operation: SubscriptionOperation;
|
|
47
|
+
/** The current row data (null for DELETE if row is no longer visible) */
|
|
48
|
+
data: T | null;
|
|
49
|
+
/** Previous field values (populated on UPDATE when available) */
|
|
50
|
+
previousValues?: Partial<T>;
|
|
51
|
+
/** Server-side timestamp of when the change occurred */
|
|
52
|
+
timestamp: string;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Options for creating a subscription.
|
|
56
|
+
*
|
|
57
|
+
* @typeParam T - The row type of the subscribed table
|
|
58
|
+
* @typeParam TFilter - The filter type for the table
|
|
59
|
+
*/
|
|
60
|
+
export interface SubscribeOptions<T, TFilter = Record<string, unknown>> {
|
|
61
|
+
/** Server-side filter to limit which events are delivered */
|
|
62
|
+
filter?: TFilter;
|
|
63
|
+
/** Called when a subscription event is received */
|
|
64
|
+
onEvent: (event: SubscriptionEvent<T>) => void;
|
|
65
|
+
/** Called when the subscription encounters an error */
|
|
66
|
+
onError?: (error: Error) => void;
|
|
67
|
+
/** Called when the subscription completes (server-initiated close) */
|
|
68
|
+
onComplete?: () => void;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Metadata about a subscription field, used internally to map
|
|
72
|
+
* table names to GraphQL subscription field names and types.
|
|
73
|
+
*/
|
|
74
|
+
export interface SubscriptionFieldMeta {
|
|
75
|
+
/** The GraphQL subscription field name (e.g., 'onContactChanged') */
|
|
76
|
+
fieldName: string;
|
|
77
|
+
/** The table name in the source schema (e.g., 'contact') */
|
|
78
|
+
tableName: string;
|
|
79
|
+
/** The data field name inside the subscription payload (e.g., 'contact') */
|
|
80
|
+
dataFieldName: string;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Configuration for the realtime (WebSocket) connection.
|
|
84
|
+
* Pass this as the `realtime` option in OrmClientConfig.
|
|
85
|
+
*
|
|
86
|
+
* @example
|
|
87
|
+
* ```ts
|
|
88
|
+
* import { createClient } from 'graphql-ws';
|
|
89
|
+
*
|
|
90
|
+
* const client = createOrmClient({
|
|
91
|
+
* endpoint: 'https://api.example.com/graphql',
|
|
92
|
+
* realtime: {
|
|
93
|
+
* client: createClient({ url: 'wss://api.example.com/graphql' }),
|
|
94
|
+
* },
|
|
95
|
+
* });
|
|
96
|
+
* ```
|
|
97
|
+
*/
|
|
98
|
+
export interface RealtimeConfig {
|
|
99
|
+
/**
|
|
100
|
+
* A graphql-ws Client instance (or any object satisfying WsClient).
|
|
101
|
+
* The consumer creates this themselves, giving full control over
|
|
102
|
+
* connection options, auth, and transport.
|
|
103
|
+
*
|
|
104
|
+
* @example
|
|
105
|
+
* ```ts
|
|
106
|
+
* import { createClient } from 'graphql-ws';
|
|
107
|
+
* const wsClient = createClient({ url: 'wss://...' });
|
|
108
|
+
* ```
|
|
109
|
+
*/
|
|
110
|
+
client: WsClient;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Manages a graphql-ws WebSocket client and multiplexes
|
|
114
|
+
* subscriptions over it. Created by OrmClient when `realtime`
|
|
115
|
+
* config is provided.
|
|
116
|
+
*/
|
|
117
|
+
export declare class RealtimeManager {
|
|
118
|
+
private wsClient;
|
|
119
|
+
private connectionState;
|
|
120
|
+
private stateListeners;
|
|
121
|
+
private activeSubscriptions;
|
|
122
|
+
constructor(config: RealtimeConfig);
|
|
123
|
+
/**
|
|
124
|
+
* Subscribe to a GraphQL subscription operation.
|
|
125
|
+
* Models call this with typed metadata and documents.
|
|
126
|
+
*/
|
|
127
|
+
subscribe<T>(meta: SubscriptionFieldMeta, document: string, variables: Record<string, unknown>, options: {
|
|
128
|
+
onEvent: (event: SubscriptionEvent<T>) => void;
|
|
129
|
+
onError?: (error: Error) => void;
|
|
130
|
+
onComplete?: () => void;
|
|
131
|
+
}): Unsubscribe;
|
|
132
|
+
/** Register a listener for connection state changes */
|
|
133
|
+
onConnectionStateChange(listener: ConnectionStateListener): Unsubscribe;
|
|
134
|
+
/** Get current connection state */
|
|
135
|
+
getConnectionState(): ConnectionState;
|
|
136
|
+
/** Number of active subscriptions */
|
|
137
|
+
getActiveSubscriptionCount(): number;
|
|
138
|
+
/** Dispose the manager and close the WebSocket connection */
|
|
139
|
+
dispose(): void;
|
|
140
|
+
private setConnectionState;
|
|
141
|
+
}
|
|
142
|
+
export {};
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Realtime Manager - WebSocket subscription support
|
|
3
|
+
* @generated by @constructive-io/graphql-codegen
|
|
4
|
+
* DO NOT EDIT - changes will be overwritten
|
|
5
|
+
*/
|
|
6
|
+
// Minimal type shims so this module compiles without graphql-ws
|
|
7
|
+
// installed. Consumers supply a WsClient via RealtimeConfig;
|
|
8
|
+
// the SDK itself never imports or requires graphql-ws.
|
|
9
|
+
// ============================================================================
|
|
10
|
+
// RealtimeManager
|
|
11
|
+
// ============================================================================
|
|
12
|
+
/**
|
|
13
|
+
* Manages a graphql-ws WebSocket client and multiplexes
|
|
14
|
+
* subscriptions over it. Created by OrmClient when `realtime`
|
|
15
|
+
* config is provided.
|
|
16
|
+
*/
|
|
17
|
+
export class RealtimeManager {
|
|
18
|
+
wsClient;
|
|
19
|
+
connectionState = 'disconnected';
|
|
20
|
+
stateListeners = new Set();
|
|
21
|
+
activeSubscriptions = 0;
|
|
22
|
+
constructor(config) {
|
|
23
|
+
this.wsClient = config.client;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Subscribe to a GraphQL subscription operation.
|
|
27
|
+
* Models call this with typed metadata and documents.
|
|
28
|
+
*/
|
|
29
|
+
subscribe(meta, document, variables, options) {
|
|
30
|
+
this.activeSubscriptions++;
|
|
31
|
+
let disposed = false;
|
|
32
|
+
const cleanup = this.wsClient.subscribe({ query: document, variables }, {
|
|
33
|
+
next: (result) => {
|
|
34
|
+
if (disposed)
|
|
35
|
+
return;
|
|
36
|
+
if (result.errors) {
|
|
37
|
+
options.onError?.(new Error(result.errors.map((e) => e.message).join('; ')));
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
const payload = result.data?.[meta.fieldName];
|
|
41
|
+
if (!payload)
|
|
42
|
+
return;
|
|
43
|
+
const event = {
|
|
44
|
+
operation: payload.event ?? 'UPDATE',
|
|
45
|
+
data: payload[meta.dataFieldName] ?? null,
|
|
46
|
+
previousValues: payload.previousValues,
|
|
47
|
+
timestamp: payload.timestamp ?? new Date().toISOString(),
|
|
48
|
+
};
|
|
49
|
+
options.onEvent(event);
|
|
50
|
+
},
|
|
51
|
+
error: (err) => {
|
|
52
|
+
if (disposed)
|
|
53
|
+
return;
|
|
54
|
+
options.onError?.(err instanceof Error ? err : new Error(String(err)));
|
|
55
|
+
},
|
|
56
|
+
complete: () => {
|
|
57
|
+
if (disposed)
|
|
58
|
+
return;
|
|
59
|
+
options.onComplete?.();
|
|
60
|
+
},
|
|
61
|
+
});
|
|
62
|
+
return () => {
|
|
63
|
+
if (disposed)
|
|
64
|
+
return;
|
|
65
|
+
disposed = true;
|
|
66
|
+
this.activeSubscriptions--;
|
|
67
|
+
cleanup();
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
/** Register a listener for connection state changes */
|
|
71
|
+
onConnectionStateChange(listener) {
|
|
72
|
+
this.stateListeners.add(listener);
|
|
73
|
+
return () => {
|
|
74
|
+
this.stateListeners.delete(listener);
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
/** Get current connection state */
|
|
78
|
+
getConnectionState() {
|
|
79
|
+
return this.connectionState;
|
|
80
|
+
}
|
|
81
|
+
/** Number of active subscriptions */
|
|
82
|
+
getActiveSubscriptionCount() {
|
|
83
|
+
return this.activeSubscriptions;
|
|
84
|
+
}
|
|
85
|
+
/** Dispose the manager and close the WebSocket connection */
|
|
86
|
+
dispose() {
|
|
87
|
+
this.wsClient.dispose();
|
|
88
|
+
this.stateListeners.clear();
|
|
89
|
+
this.activeSubscriptions = 0;
|
|
90
|
+
this.setConnectionState('disconnected');
|
|
91
|
+
}
|
|
92
|
+
setConnectionState(state) {
|
|
93
|
+
if (this.connectionState === state)
|
|
94
|
+
return;
|
|
95
|
+
this.connectionState = state;
|
|
96
|
+
for (const listener of this.stateListeners) {
|
|
97
|
+
listener(state);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|