@standards/client 1.0.0-alpha.392 → 1.0.0-alpha.394

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/README.md CHANGED
@@ -1,17 +1,17 @@
1
1
  # @standards/client
2
2
 
3
- Declare your schema with the `@standards/schema` fluent builders, sync it to a hosted Standards tenant, and operate typed records — from any Node ≥ 22 server process. No runtime, no NestJS.
3
+ Declare your schema as a bundle with the `@standards/schema` fluent builders, sync it to a hosted Standards tenant, and operate typed records — from any Node ≥ 22 server process. No runtime, no NestJS.
4
4
 
5
5
  ```bash
6
6
  pnpm add @standards/client
7
7
  ```
8
8
 
9
- Everything you need — the builders, `createStandards`, `defineSchemaSource`, error classes — is exported from `@standards/client`. One package, one version.
9
+ Everything you need — the builders, `bundle`, `createStandards`, error classes — is exported from `@standards/client`. One package, one version.
10
10
 
11
- ## 1. Declare a source
11
+ ## 1. Declare a bundle
12
12
 
13
13
  ```ts
14
- import { date, defineSchemaSource, object, select, text } from "@standards/client";
14
+ import { bundle, date, object, select, text } from "@standards/client";
15
15
 
16
16
  export const incident = object("incidents", "Incident")
17
17
  .attribute(text("title", "Title").required())
@@ -25,7 +25,7 @@ export const incident = object("incidents", "Incident")
25
25
  .attribute(date("startedAt", "Started at"))
26
26
  .labelExpression("{{ title }}");
27
27
 
28
- export const statusSource = defineSchemaSource({ id: "status-site", objects: [incident] });
28
+ export const status = bundle("status-site", "Status site").add(incident);
29
29
  ```
30
30
 
31
31
  ## 2. Sync it (server-side only)
@@ -37,16 +37,16 @@ import { createStandards } from "@standards/client";
37
37
  // Create the key with a role granting architect:update (`standards keys create --role`); keys default to member.
38
38
  const standards = createStandards();
39
39
 
40
- const result = await standards.schema.sync(statusSource);
41
- // { applied: false, hash } when nothing changed — one GET, no write.
40
+ const result = await standards.bundles.sync(status);
41
+ // { applied: false, hash } when the workspace already holds this version: one GET, no write.
42
42
  ```
43
43
 
44
- Objects you push are **system**: users can add their own attributes and views on top, but cannot delete or retype yours. Remove an object from the source and it is demoted to a custom object — its records survive. Never call `createStandards` with an API key in browser code; it refuses to.
44
+ Objects you sync are **system**: users can add their own attributes and views on top, but cannot delete or retype yours. Remove an object from the bundle and it is demoted to a custom object — its records survive. Never call `createStandards` with an API key in browser code; it refuses to.
45
45
 
46
46
  ## 3. Typed records
47
47
 
48
48
  ```ts
49
- const db = createStandards({ baseUrl, apiKey, schema: statusSource });
49
+ const db = createStandards({ baseUrl, apiKey, bundles: [status] });
50
50
  const incidents = db.incidents; // one typed query per object, keyed by the camelCase of its name
51
51
 
52
52
  await incidents.create({ title: "API latency", severity: "major", startedAt: new Date() });
@@ -57,6 +57,6 @@ Inputs are typed from the builder (`severity` only accepts the three options); d
57
57
 
58
58
  ## Errors
59
59
 
60
- `StandardsAuthError` (401/403), `SchemaSourceConflictError` (409 from `schema.sync`, with `objectName` and `owner`), `SchemaSourceValidationError` (400 from `schema.sync`, server message verbatim), `StandardsRequestError` (any other non-2xx, with the server's `code`), `StandardsConfigurationError` (misuse). `schema.sync` never throws for "nothing to do".
60
+ `StandardsAuthError` (401/403), `BundleConflictError` (409 from `bundles.sync`, with `objectName` and `owner`), `BundleValidationError` (400 from `bundles.sync`, server message verbatim), `StandardsRequestError` (any other non-2xx, with the server's `code`), `StandardsConfigurationError` (misuse). `bundles.sync` never throws for "nothing to do".
61
61
 
62
62
  Licensed under the Standards SDK License 1.0 — see `LICENSE`. This package is not open source: it is provided to build applications that communicate with Standards.
package/dist/app.d.mts CHANGED
@@ -1,6 +1,7 @@
1
1
 
2
- import { _ as StandardsRequestError, a as OperationStreamOptions, c as UploadProgress, d as readRefusal, f as refusalOf, h as StandardsAuthError, i as OperationCallOptions, l as createHttpTransport, n as HttpTransportConfig, t as HttpTransport } from "./http-transport-DBgedLFQ.mjs";
3
- import { Operation, OperationInput, OperationResult, actorsOperations, agentAccessOperations, agentApprovalsOperations, agentDefinitionsOperations, agentEnvVarsOperations, agentMemoryOperations, agentMessagesOperations, agentRolesOperations, agentRunsOperations, agentSessionsOperations, agentTriggersOperations, aiOperations, apiKeysOperations, artifactsOperations, auditOperations, browserProfilesOperations, bundlesOperations, catalogOperations, cloudBrowsersOperations, connectorsOperations, devicesOperations, dictationOperations, documentsOperations, emailCategoriesOperations, emailClassificationOperations, emailsOperations, embeddingsAdminOperations, envVarsOperations, environmentsOperations, filesOperations, foldersOperations, formsOperations, geocodingOperations, logosOperations, mailDraftsOperations, mcpServersOperations, meetingsAdminOperations, meetingsOperations, memoryAdminOperations, modelsOperations, newsOperations, notificationsOperations, pageAccessOperations, pagesOperations, permissionsOperations, privateEnvVarsOperations, quotasOperations, recentActivityOperations, recordAccessOperations, recordOperationsOperations, recordsOperations, relationsOperations, schemaDraftOperations, schemaGroupsOperations, schemaObjectsOperations, schemaSourcesOperations, schemaStateOperations, searchAdminOperations, searchOperations, tenantInvitationsOperations, tenantSettingsOperations, usersOperations, viewsOperations, workspaceLoginsOperations } from "@standards/schema/api";
2
+ import { _ as StandardsRequestError, a as OperationStreamOptions, c as UploadProgress, d as readRefusal, f as refusalOf, h as StandardsAuthError, i as OperationCallOptions, l as createHttpTransport, n as HttpTransportConfig, t as HttpTransport } from "./http-transport-C1u5UGkC.mjs";
3
+ import { DraftConflictChange } from "@standards/schema";
4
+ import { Operation, OperationInput, OperationResult, actorsOperations, agentAccessOperations, agentApprovalsOperations, agentDefinitionsOperations, agentEnvVarsOperations, agentMemoryOperations, agentMessagesOperations, agentRolesOperations, agentRunsOperations, agentSessionsOperations, agentTriggersOperations, aiOperations, apiKeysOperations, artifactsOperations, auditOperations, browserProfilesOperations, bundlesOperations, cloudBrowsersOperations, connectorsOperations, devicesOperations, dictationOperations, documentsOperations, emailCategoriesOperations, emailClassificationOperations, emailsOperations, embeddingsAdminOperations, envVarsOperations, environmentsOperations, filesOperations, foldersOperations, formsOperations, geocodingOperations, logosOperations, mailDraftsOperations, mcpServersOperations, meetingsAdminOperations, meetingsOperations, memoryAdminOperations, modelsOperations, newsOperations, notificationsOperations, pageAccessOperations, pagesOperations, permissionsOperations, privateEnvVarsOperations, quotasOperations, recentActivityOperations, recordAccessOperations, recordOperationsOperations, recordsOperations, relationsOperations, schemaDraftOperations, schemaGroupsOperations, schemaObjectsOperations, schemaStateOperations, searchAdminOperations, searchOperations, tenantInvitationsOperations, tenantSettingsOperations, usersOperations, viewsOperations, workspaceLoginsOperations } from "@standards/schema/api";
4
5
  //#region src/app-errors.d.ts
5
6
  /** The server's `SchemaErrorCode` on a failed call, when it sent one. */
6
7
  export declare function schemaApiErrorCode(error: unknown): string | undefined;
@@ -23,6 +24,12 @@ export declare function isObjectNotFound(error: unknown): boolean;
23
24
  * next attempt mean something (#4899).
24
25
  */
25
26
  export declare function isDraftRevisionConflict(error: unknown): boolean;
27
+ /**
28
+ * What a publish refused for a conflict found published on its targets since
29
+ * the draft captured them (#5936). Empty for any other refusal, a conflict on
30
+ * the draft's own revision included: that one is answered by reading it again.
31
+ */
32
+ export declare function draftConflictChanges(error: unknown): DraftConflictChange[];
26
33
  /**
27
34
  * Whether a view read failed because the object simply has no view for that
28
35
  * context (#2659) — a working object not laid out yet, not a failure.
@@ -51,7 +58,7 @@ export declare function parseContentDispositionFilename(header: string | null |
51
58
  //#endregion
52
59
  //#region src/app.d.ts
53
60
  type GroupOperation<G> = G[keyof G];
54
- type AppOperation = GroupOperation<typeof apiKeysOperations> | GroupOperation<typeof meetingsOperations> | GroupOperation<typeof quotasOperations> | GroupOperation<typeof aiOperations> | GroupOperation<typeof modelsOperations> | GroupOperation<typeof agentMemoryOperations> | GroupOperation<typeof schemaGroupsOperations> | GroupOperation<typeof artifactsOperations> | GroupOperation<typeof envVarsOperations> | GroupOperation<typeof privateEnvVarsOperations> | GroupOperation<typeof workspaceLoginsOperations> | GroupOperation<typeof tenantSettingsOperations> | GroupOperation<typeof tenantInvitationsOperations> | GroupOperation<typeof notificationsOperations> | GroupOperation<typeof bundlesOperations> | GroupOperation<typeof catalogOperations> | GroupOperation<typeof auditOperations> | GroupOperation<typeof geocodingOperations> | GroupOperation<typeof logosOperations> | GroupOperation<typeof actorsOperations> | GroupOperation<typeof usersOperations> | GroupOperation<typeof permissionsOperations> | GroupOperation<typeof agentAccessOperations> | GroupOperation<typeof pageAccessOperations> | GroupOperation<typeof browserProfilesOperations> | GroupOperation<typeof cloudBrowsersOperations> | GroupOperation<typeof environmentsOperations> | GroupOperation<typeof mcpServersOperations> | GroupOperation<typeof connectorsOperations> | GroupOperation<typeof emailCategoriesOperations> | GroupOperation<typeof emailClassificationOperations> | GroupOperation<typeof emailsOperations> | GroupOperation<typeof mailDraftsOperations> | GroupOperation<typeof pagesOperations> | GroupOperation<typeof viewsOperations> | GroupOperation<typeof formsOperations> | GroupOperation<typeof relationsOperations> | GroupOperation<typeof searchOperations> | GroupOperation<typeof recentActivityOperations> | GroupOperation<typeof recordOperationsOperations> | GroupOperation<typeof recordsOperations> | GroupOperation<typeof recordAccessOperations> | GroupOperation<typeof newsOperations> | GroupOperation<typeof meetingsAdminOperations> | GroupOperation<typeof embeddingsAdminOperations> | GroupOperation<typeof memoryAdminOperations> | GroupOperation<typeof searchAdminOperations> | GroupOperation<typeof schemaStateOperations> | GroupOperation<typeof schemaSourcesOperations> | GroupOperation<typeof schemaObjectsOperations> | GroupOperation<typeof schemaDraftOperations> | GroupOperation<typeof filesOperations> | GroupOperation<typeof documentsOperations> | GroupOperation<typeof foldersOperations> | GroupOperation<typeof agentDefinitionsOperations> | GroupOperation<typeof agentRolesOperations> | GroupOperation<typeof agentEnvVarsOperations> | GroupOperation<typeof agentRunsOperations> | GroupOperation<typeof agentTriggersOperations> | GroupOperation<typeof agentSessionsOperations> | GroupOperation<typeof agentMessagesOperations> | GroupOperation<typeof agentApprovalsOperations> | GroupOperation<typeof devicesOperations> | GroupOperation<typeof dictationOperations>;
61
+ type AppOperation = GroupOperation<typeof apiKeysOperations> | GroupOperation<typeof meetingsOperations> | GroupOperation<typeof quotasOperations> | GroupOperation<typeof aiOperations> | GroupOperation<typeof modelsOperations> | GroupOperation<typeof agentMemoryOperations> | GroupOperation<typeof schemaGroupsOperations> | GroupOperation<typeof artifactsOperations> | GroupOperation<typeof envVarsOperations> | GroupOperation<typeof privateEnvVarsOperations> | GroupOperation<typeof workspaceLoginsOperations> | GroupOperation<typeof tenantSettingsOperations> | GroupOperation<typeof tenantInvitationsOperations> | GroupOperation<typeof notificationsOperations> | GroupOperation<typeof bundlesOperations> | GroupOperation<typeof auditOperations> | GroupOperation<typeof geocodingOperations> | GroupOperation<typeof logosOperations> | GroupOperation<typeof actorsOperations> | GroupOperation<typeof usersOperations> | GroupOperation<typeof permissionsOperations> | GroupOperation<typeof agentAccessOperations> | GroupOperation<typeof pageAccessOperations> | GroupOperation<typeof browserProfilesOperations> | GroupOperation<typeof cloudBrowsersOperations> | GroupOperation<typeof environmentsOperations> | GroupOperation<typeof mcpServersOperations> | GroupOperation<typeof connectorsOperations> | GroupOperation<typeof emailCategoriesOperations> | GroupOperation<typeof emailClassificationOperations> | GroupOperation<typeof emailsOperations> | GroupOperation<typeof mailDraftsOperations> | GroupOperation<typeof pagesOperations> | GroupOperation<typeof viewsOperations> | GroupOperation<typeof formsOperations> | GroupOperation<typeof relationsOperations> | GroupOperation<typeof searchOperations> | GroupOperation<typeof recentActivityOperations> | GroupOperation<typeof recordOperationsOperations> | GroupOperation<typeof recordsOperations> | GroupOperation<typeof recordAccessOperations> | GroupOperation<typeof newsOperations> | GroupOperation<typeof meetingsAdminOperations> | GroupOperation<typeof embeddingsAdminOperations> | GroupOperation<typeof memoryAdminOperations> | GroupOperation<typeof searchAdminOperations> | GroupOperation<typeof schemaStateOperations> | GroupOperation<typeof schemaObjectsOperations> | GroupOperation<typeof schemaDraftOperations> | GroupOperation<typeof filesOperations> | GroupOperation<typeof documentsOperations> | GroupOperation<typeof foldersOperations> | GroupOperation<typeof agentDefinitionsOperations> | GroupOperation<typeof agentRolesOperations> | GroupOperation<typeof agentEnvVarsOperations> | GroupOperation<typeof agentRunsOperations> | GroupOperation<typeof agentTriggersOperations> | GroupOperation<typeof agentSessionsOperations> | GroupOperation<typeof agentMessagesOperations> | GroupOperation<typeof agentApprovalsOperations> | GroupOperation<typeof devicesOperations> | GroupOperation<typeof dictationOperations>;
55
62
  type NamespaceOf<N> = N extends `${infer G}.${string}` ? G : never;
56
63
  type VerbOf<N> = N extends `${string}.${infer V}` ? V : never;
57
64
  /** An `"events"` operation opens a stream (`transport.stream`); any other is one call. */
package/dist/app.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
 
2
- import { _ as StandardsRequestError, a as OperationStreamOptions, c as UploadProgress, d as readRefusal, f as refusalOf, h as StandardsAuthError, i as OperationCallOptions, l as createHttpTransport, n as HttpTransportConfig, t as HttpTransport } from "./http-transport-DBgedLFQ.js";
3
- import { Operation, OperationInput, OperationResult, actorsOperations, agentAccessOperations, agentApprovalsOperations, agentDefinitionsOperations, agentEnvVarsOperations, agentMemoryOperations, agentMessagesOperations, agentRolesOperations, agentRunsOperations, agentSessionsOperations, agentTriggersOperations, aiOperations, apiKeysOperations, artifactsOperations, auditOperations, browserProfilesOperations, bundlesOperations, catalogOperations, cloudBrowsersOperations, connectorsOperations, devicesOperations, dictationOperations, documentsOperations, emailCategoriesOperations, emailClassificationOperations, emailsOperations, embeddingsAdminOperations, envVarsOperations, environmentsOperations, filesOperations, foldersOperations, formsOperations, geocodingOperations, logosOperations, mailDraftsOperations, mcpServersOperations, meetingsAdminOperations, meetingsOperations, memoryAdminOperations, modelsOperations, newsOperations, notificationsOperations, pageAccessOperations, pagesOperations, permissionsOperations, privateEnvVarsOperations, quotasOperations, recentActivityOperations, recordAccessOperations, recordOperationsOperations, recordsOperations, relationsOperations, schemaDraftOperations, schemaGroupsOperations, schemaObjectsOperations, schemaSourcesOperations, schemaStateOperations, searchAdminOperations, searchOperations, tenantInvitationsOperations, tenantSettingsOperations, usersOperations, viewsOperations, workspaceLoginsOperations } from "@standards/schema/api";
2
+ import { _ as StandardsRequestError, a as OperationStreamOptions, c as UploadProgress, d as readRefusal, f as refusalOf, h as StandardsAuthError, i as OperationCallOptions, l as createHttpTransport, n as HttpTransportConfig, t as HttpTransport } from "./http-transport-C1u5UGkC.js";
3
+ import { Operation, OperationInput, OperationResult, actorsOperations, agentAccessOperations, agentApprovalsOperations, agentDefinitionsOperations, agentEnvVarsOperations, agentMemoryOperations, agentMessagesOperations, agentRolesOperations, agentRunsOperations, agentSessionsOperations, agentTriggersOperations, aiOperations, apiKeysOperations, artifactsOperations, auditOperations, browserProfilesOperations, bundlesOperations, cloudBrowsersOperations, connectorsOperations, devicesOperations, dictationOperations, documentsOperations, emailCategoriesOperations, emailClassificationOperations, emailsOperations, embeddingsAdminOperations, envVarsOperations, environmentsOperations, filesOperations, foldersOperations, formsOperations, geocodingOperations, logosOperations, mailDraftsOperations, mcpServersOperations, meetingsAdminOperations, meetingsOperations, memoryAdminOperations, modelsOperations, newsOperations, notificationsOperations, pageAccessOperations, pagesOperations, permissionsOperations, privateEnvVarsOperations, quotasOperations, recentActivityOperations, recordAccessOperations, recordOperationsOperations, recordsOperations, relationsOperations, schemaDraftOperations, schemaGroupsOperations, schemaObjectsOperations, schemaStateOperations, searchAdminOperations, searchOperations, tenantInvitationsOperations, tenantSettingsOperations, usersOperations, viewsOperations, workspaceLoginsOperations } from "@standards/schema/api";
4
+ import { DraftConflictChange } from "@standards/schema";
4
5
  //#region src/app-errors.d.ts
5
6
  /** The server's `SchemaErrorCode` on a failed call, when it sent one. */
6
7
  export declare function schemaApiErrorCode(error: unknown): string | undefined;
@@ -23,6 +24,12 @@ export declare function isObjectNotFound(error: unknown): boolean;
23
24
  * next attempt mean something (#4899).
24
25
  */
25
26
  export declare function isDraftRevisionConflict(error: unknown): boolean;
27
+ /**
28
+ * What a publish refused for a conflict found published on its targets since
29
+ * the draft captured them (#5936). Empty for any other refusal, a conflict on
30
+ * the draft's own revision included: that one is answered by reading it again.
31
+ */
32
+ export declare function draftConflictChanges(error: unknown): DraftConflictChange[];
26
33
  /**
27
34
  * Whether a view read failed because the object simply has no view for that
28
35
  * context (#2659) — a working object not laid out yet, not a failure.
@@ -51,7 +58,7 @@ export declare function parseContentDispositionFilename(header: string | null |
51
58
  //#endregion
52
59
  //#region src/app.d.ts
53
60
  type GroupOperation<G> = G[keyof G];
54
- type AppOperation = GroupOperation<typeof apiKeysOperations> | GroupOperation<typeof meetingsOperations> | GroupOperation<typeof quotasOperations> | GroupOperation<typeof aiOperations> | GroupOperation<typeof modelsOperations> | GroupOperation<typeof agentMemoryOperations> | GroupOperation<typeof schemaGroupsOperations> | GroupOperation<typeof artifactsOperations> | GroupOperation<typeof envVarsOperations> | GroupOperation<typeof privateEnvVarsOperations> | GroupOperation<typeof workspaceLoginsOperations> | GroupOperation<typeof tenantSettingsOperations> | GroupOperation<typeof tenantInvitationsOperations> | GroupOperation<typeof notificationsOperations> | GroupOperation<typeof bundlesOperations> | GroupOperation<typeof catalogOperations> | GroupOperation<typeof auditOperations> | GroupOperation<typeof geocodingOperations> | GroupOperation<typeof logosOperations> | GroupOperation<typeof actorsOperations> | GroupOperation<typeof usersOperations> | GroupOperation<typeof permissionsOperations> | GroupOperation<typeof agentAccessOperations> | GroupOperation<typeof pageAccessOperations> | GroupOperation<typeof browserProfilesOperations> | GroupOperation<typeof cloudBrowsersOperations> | GroupOperation<typeof environmentsOperations> | GroupOperation<typeof mcpServersOperations> | GroupOperation<typeof connectorsOperations> | GroupOperation<typeof emailCategoriesOperations> | GroupOperation<typeof emailClassificationOperations> | GroupOperation<typeof emailsOperations> | GroupOperation<typeof mailDraftsOperations> | GroupOperation<typeof pagesOperations> | GroupOperation<typeof viewsOperations> | GroupOperation<typeof formsOperations> | GroupOperation<typeof relationsOperations> | GroupOperation<typeof searchOperations> | GroupOperation<typeof recentActivityOperations> | GroupOperation<typeof recordOperationsOperations> | GroupOperation<typeof recordsOperations> | GroupOperation<typeof recordAccessOperations> | GroupOperation<typeof newsOperations> | GroupOperation<typeof meetingsAdminOperations> | GroupOperation<typeof embeddingsAdminOperations> | GroupOperation<typeof memoryAdminOperations> | GroupOperation<typeof searchAdminOperations> | GroupOperation<typeof schemaStateOperations> | GroupOperation<typeof schemaSourcesOperations> | GroupOperation<typeof schemaObjectsOperations> | GroupOperation<typeof schemaDraftOperations> | GroupOperation<typeof filesOperations> | GroupOperation<typeof documentsOperations> | GroupOperation<typeof foldersOperations> | GroupOperation<typeof agentDefinitionsOperations> | GroupOperation<typeof agentRolesOperations> | GroupOperation<typeof agentEnvVarsOperations> | GroupOperation<typeof agentRunsOperations> | GroupOperation<typeof agentTriggersOperations> | GroupOperation<typeof agentSessionsOperations> | GroupOperation<typeof agentMessagesOperations> | GroupOperation<typeof agentApprovalsOperations> | GroupOperation<typeof devicesOperations> | GroupOperation<typeof dictationOperations>;
61
+ type AppOperation = GroupOperation<typeof apiKeysOperations> | GroupOperation<typeof meetingsOperations> | GroupOperation<typeof quotasOperations> | GroupOperation<typeof aiOperations> | GroupOperation<typeof modelsOperations> | GroupOperation<typeof agentMemoryOperations> | GroupOperation<typeof schemaGroupsOperations> | GroupOperation<typeof artifactsOperations> | GroupOperation<typeof envVarsOperations> | GroupOperation<typeof privateEnvVarsOperations> | GroupOperation<typeof workspaceLoginsOperations> | GroupOperation<typeof tenantSettingsOperations> | GroupOperation<typeof tenantInvitationsOperations> | GroupOperation<typeof notificationsOperations> | GroupOperation<typeof bundlesOperations> | GroupOperation<typeof auditOperations> | GroupOperation<typeof geocodingOperations> | GroupOperation<typeof logosOperations> | GroupOperation<typeof actorsOperations> | GroupOperation<typeof usersOperations> | GroupOperation<typeof permissionsOperations> | GroupOperation<typeof agentAccessOperations> | GroupOperation<typeof pageAccessOperations> | GroupOperation<typeof browserProfilesOperations> | GroupOperation<typeof cloudBrowsersOperations> | GroupOperation<typeof environmentsOperations> | GroupOperation<typeof mcpServersOperations> | GroupOperation<typeof connectorsOperations> | GroupOperation<typeof emailCategoriesOperations> | GroupOperation<typeof emailClassificationOperations> | GroupOperation<typeof emailsOperations> | GroupOperation<typeof mailDraftsOperations> | GroupOperation<typeof pagesOperations> | GroupOperation<typeof viewsOperations> | GroupOperation<typeof formsOperations> | GroupOperation<typeof relationsOperations> | GroupOperation<typeof searchOperations> | GroupOperation<typeof recentActivityOperations> | GroupOperation<typeof recordOperationsOperations> | GroupOperation<typeof recordsOperations> | GroupOperation<typeof recordAccessOperations> | GroupOperation<typeof newsOperations> | GroupOperation<typeof meetingsAdminOperations> | GroupOperation<typeof embeddingsAdminOperations> | GroupOperation<typeof memoryAdminOperations> | GroupOperation<typeof searchAdminOperations> | GroupOperation<typeof schemaStateOperations> | GroupOperation<typeof schemaObjectsOperations> | GroupOperation<typeof schemaDraftOperations> | GroupOperation<typeof filesOperations> | GroupOperation<typeof documentsOperations> | GroupOperation<typeof foldersOperations> | GroupOperation<typeof agentDefinitionsOperations> | GroupOperation<typeof agentRolesOperations> | GroupOperation<typeof agentEnvVarsOperations> | GroupOperation<typeof agentRunsOperations> | GroupOperation<typeof agentTriggersOperations> | GroupOperation<typeof agentSessionsOperations> | GroupOperation<typeof agentMessagesOperations> | GroupOperation<typeof agentApprovalsOperations> | GroupOperation<typeof devicesOperations> | GroupOperation<typeof dictationOperations>;
55
62
  type NamespaceOf<N> = N extends `${infer G}.${string}` ? G : never;
56
63
  type VerbOf<N> = N extends `${string}.${infer V}` ? V : never;
57
64
  /** An `"events"` operation opens a stream (`transport.stream`); any other is one call. */
package/dist/app.js CHANGED
@@ -1,2 +1,2 @@
1
1
  /*! © 2025-2026 AND YOU CREATE SAS (RCS Paris 940 190 614). Proprietary — see LICENSE (Standards SDK License 1.0). */
2
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./http-transport-DHbErYa4.js");let t=require("@standards/schema/api");const n=[t.apiKeysOperations,t.meetingsOperations,t.quotasOperations,t.aiOperations,t.modelsOperations,t.agentMemoryOperations,t.schemaGroupsOperations,t.artifactsOperations,t.envVarsOperations,t.privateEnvVarsOperations,t.workspaceLoginsOperations,t.tenantSettingsOperations,t.tenantInvitationsOperations,t.notificationsOperations,t.bundlesOperations,t.catalogOperations,t.auditOperations,t.geocodingOperations,t.logosOperations,t.actorsOperations,t.usersOperations,t.permissionsOperations,t.agentAccessOperations,t.pageAccessOperations,t.browserProfilesOperations,t.cloudBrowsersOperations,t.environmentsOperations,t.mcpServersOperations,t.connectorsOperations,t.emailCategoriesOperations,t.emailClassificationOperations,t.emailsOperations,t.mailDraftsOperations,t.pagesOperations,t.viewsOperations,t.formsOperations,t.relationsOperations,t.searchOperations,t.recentActivityOperations,t.recordOperationsOperations,t.recordsOperations,t.recordAccessOperations,t.newsOperations,t.meetingsAdminOperations,t.embeddingsAdminOperations,t.memoryAdminOperations,t.searchAdminOperations,t.schemaStateOperations,t.schemaSourcesOperations,t.schemaObjectsOperations,t.schemaDraftOperations,t.filesOperations,t.documentsOperations,t.foldersOperations,t.agentDefinitionsOperations,t.agentRolesOperations,t.agentEnvVarsOperations,t.agentRunsOperations,t.agentTriggersOperations,t.agentSessionsOperations,t.agentMessagesOperations,t.agentApprovalsOperations,t.devicesOperations,t.dictationOperations];function createAppClient(e){let r={};for(let i of n.flatMap(e=>Object.values(e))){let n=(0,t.operationGroup)(i),a=i.name.slice(n.length+1);r[n]??={},r[n][a]=(t,n)=>i.response===`events`?e.stream(i,t,n):e.call(i,t,n)}return r}exports.StandardsAuthError=e.m,exports.StandardsRequestError=e.g,exports.createAppClient=createAppClient,exports.createHttpTransport=e.t,exports.isDraftRevisionConflict=e.s,exports.isObjectNotFound=e.c,exports.isPermanentRefusal=e.l,exports.isViewNotFound=e.u,exports.parseContentDispositionFilename=e.o,exports.readRefusal=e.r,exports.refusalOf=e.i,exports.schemaApiErrorCode=e.d;
2
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./http-transport-CAPVZuiv.js");let t=require("@standards/schema/api");const n=[t.apiKeysOperations,t.meetingsOperations,t.quotasOperations,t.aiOperations,t.modelsOperations,t.agentMemoryOperations,t.schemaGroupsOperations,t.artifactsOperations,t.envVarsOperations,t.privateEnvVarsOperations,t.workspaceLoginsOperations,t.tenantSettingsOperations,t.tenantInvitationsOperations,t.notificationsOperations,t.bundlesOperations,t.auditOperations,t.geocodingOperations,t.logosOperations,t.actorsOperations,t.usersOperations,t.permissionsOperations,t.agentAccessOperations,t.pageAccessOperations,t.browserProfilesOperations,t.cloudBrowsersOperations,t.environmentsOperations,t.mcpServersOperations,t.connectorsOperations,t.emailCategoriesOperations,t.emailClassificationOperations,t.emailsOperations,t.mailDraftsOperations,t.pagesOperations,t.viewsOperations,t.formsOperations,t.relationsOperations,t.searchOperations,t.recentActivityOperations,t.recordOperationsOperations,t.recordsOperations,t.recordAccessOperations,t.newsOperations,t.meetingsAdminOperations,t.embeddingsAdminOperations,t.memoryAdminOperations,t.searchAdminOperations,t.schemaStateOperations,t.schemaObjectsOperations,t.schemaDraftOperations,t.filesOperations,t.documentsOperations,t.foldersOperations,t.agentDefinitionsOperations,t.agentRolesOperations,t.agentEnvVarsOperations,t.agentRunsOperations,t.agentTriggersOperations,t.agentSessionsOperations,t.agentMessagesOperations,t.agentApprovalsOperations,t.devicesOperations,t.dictationOperations];function createAppClient(e){let r={};for(let i of n.flatMap(e=>Object.values(e))){let n=(0,t.operationGroup)(i),a=i.name.slice(n.length+1);r[n]??={},r[n][a]=(t,n)=>i.response===`events`?e.stream(i,t,n):e.call(i,t,n)}return r}exports.StandardsAuthError=e.h,exports.StandardsRequestError=e._,exports.createAppClient=createAppClient,exports.createHttpTransport=e.t,exports.draftConflictChanges=e.s,exports.isDraftRevisionConflict=e.c,exports.isObjectNotFound=e.l,exports.isPermanentRefusal=e.u,exports.isViewNotFound=e.d,exports.parseContentDispositionFilename=e.o,exports.readRefusal=e.r,exports.refusalOf=e.i,exports.schemaApiErrorCode=e.f;
package/dist/app.mjs CHANGED
@@ -1,2 +1,2 @@
1
1
  /*! © 2025-2026 AND YOU CREATE SAS (RCS Paris 940 190 614). Proprietary — see LICENSE (Standards SDK License 1.0). */
2
- import{c as e,d as t,g as n,i as r,l as i,m as ee,o as a,r as o,s,t as c,u as l}from"./http-transport-17TmxnFl.mjs";import{actorsOperations as u,agentAccessOperations as d,agentApprovalsOperations as f,agentDefinitionsOperations as p,agentEnvVarsOperations as m,agentMemoryOperations as h,agentMessagesOperations as g,agentRolesOperations as _,agentRunsOperations as v,agentSessionsOperations as y,agentTriggersOperations as b,aiOperations as x,apiKeysOperations as S,artifactsOperations as C,auditOperations as w,browserProfilesOperations as T,bundlesOperations as E,catalogOperations as D,cloudBrowsersOperations as O,connectorsOperations as k,devicesOperations as A,dictationOperations as j,documentsOperations as M,emailCategoriesOperations as N,emailClassificationOperations as P,emailsOperations as F,embeddingsAdminOperations as I,envVarsOperations as L,environmentsOperations as R,filesOperations as z,foldersOperations as B,formsOperations as te,geocodingOperations as V,logosOperations as H,mailDraftsOperations as U,mcpServersOperations as W,meetingsAdminOperations as G,meetingsOperations as K,memoryAdminOperations as q,modelsOperations as J,newsOperations as Y,notificationsOperations as X,operationGroup as Z,pageAccessOperations as Q,pagesOperations as ne,permissionsOperations as re,privateEnvVarsOperations as ie,quotasOperations as ae,recentActivityOperations as oe,recordAccessOperations as se,recordOperationsOperations as ce,recordsOperations as le,relationsOperations as ue,schemaDraftOperations as de,schemaGroupsOperations as fe,schemaObjectsOperations as pe,schemaSourcesOperations as $,schemaStateOperations as me,searchAdminOperations as he,searchOperations as ge,tenantInvitationsOperations as _e,tenantSettingsOperations as ve,usersOperations as ye,viewsOperations as be,workspaceLoginsOperations as xe}from"@standards/schema/api";const Se=[S,K,ae,x,J,h,fe,C,L,ie,xe,ve,_e,X,E,D,w,V,H,u,ye,re,d,Q,T,O,R,W,k,N,P,F,U,ne,be,te,ue,ge,oe,ce,le,se,Y,G,I,q,he,me,$,pe,de,z,M,B,p,_,m,v,b,y,g,f,A,j];function createAppClient(e){let t={};for(let n of Se.flatMap(e=>Object.values(e))){let r=Z(n),i=n.name.slice(r.length+1);t[r]??={},t[r][i]=(t,r)=>n.response===`events`?e.stream(n,t,r):e.call(n,t,r)}return t}export{ee as StandardsAuthError,n as StandardsRequestError,createAppClient,c as createHttpTransport,s as isDraftRevisionConflict,e as isObjectNotFound,i as isPermanentRefusal,l as isViewNotFound,a as parseContentDispositionFilename,o as readRefusal,r as refusalOf,t as schemaApiErrorCode};
2
+ import{_ as e,c as t,d as n,f as r,h as i,i as ee,l as a,o,r as s,s as c,t as l,u}from"./http-transport-BxgXm4Oi.mjs";import{actorsOperations as d,agentAccessOperations as f,agentApprovalsOperations as p,agentDefinitionsOperations as m,agentEnvVarsOperations as h,agentMemoryOperations as g,agentMessagesOperations as _,agentRolesOperations as v,agentRunsOperations as y,agentSessionsOperations as b,agentTriggersOperations as x,aiOperations as S,apiKeysOperations as C,artifactsOperations as w,auditOperations as T,browserProfilesOperations as E,bundlesOperations as D,cloudBrowsersOperations as O,connectorsOperations as k,devicesOperations as A,dictationOperations as j,documentsOperations as M,emailCategoriesOperations as N,emailClassificationOperations as P,emailsOperations as F,embeddingsAdminOperations as I,envVarsOperations as L,environmentsOperations as R,filesOperations as z,foldersOperations as B,formsOperations as te,geocodingOperations as V,logosOperations as H,mailDraftsOperations as U,mcpServersOperations as W,meetingsAdminOperations as G,meetingsOperations as K,memoryAdminOperations as q,modelsOperations as J,newsOperations as Y,notificationsOperations as X,operationGroup as Z,pageAccessOperations as Q,pagesOperations as ne,permissionsOperations as re,privateEnvVarsOperations as ie,quotasOperations as ae,recentActivityOperations as oe,recordAccessOperations as se,recordOperationsOperations as ce,recordsOperations as le,relationsOperations as ue,schemaDraftOperations as de,schemaGroupsOperations as fe,schemaObjectsOperations as pe,schemaStateOperations as $,searchAdminOperations as me,searchOperations as he,tenantInvitationsOperations as ge,tenantSettingsOperations as _e,usersOperations as ve,viewsOperations as ye,workspaceLoginsOperations as be}from"@standards/schema/api";const xe=[C,K,ae,S,J,g,fe,w,L,ie,be,_e,ge,X,D,T,V,H,d,ve,re,f,Q,E,O,R,W,k,N,P,F,U,ne,ye,te,ue,he,oe,ce,le,se,Y,G,I,q,me,$,pe,de,z,M,B,m,v,h,y,x,b,_,p,A,j];function createAppClient(e){let t={};for(let n of xe.flatMap(e=>Object.values(e))){let r=Z(n),i=n.name.slice(r.length+1);t[r]??={},t[r][i]=(t,r)=>n.response===`events`?e.stream(n,t,r):e.call(n,t,r)}return t}export{i as StandardsAuthError,e as StandardsRequestError,createAppClient,l as createHttpTransport,c as draftConflictChanges,t as isDraftRevisionConflict,a as isObjectNotFound,u as isPermanentRefusal,n as isViewNotFound,o as parseContentDispositionFilename,s as readRefusal,ee as refusalOf,r as schemaApiErrorCode};
@@ -0,0 +1,4 @@
1
+ /*! © 2025-2026 AND YOU CREATE SAS (RCS Paris 940 190 614). Proprietary — see LICENSE (Standards SDK License 1.0). */
2
+ import{_ as e,g as t,m as n,n as r,p as i}from"./http-transport-BxgXm4Oi.mjs";import{AggregateValidationError as a,DuplicateError as o,RecordQuery as s,SchemaErrorCode as c,ValidationError as l}from"@standards/schema";import{buildOperationPath as u,bundlesOperations as d,documentsOperations as f,filesOperations as p,recordAccessOperations as m,recordsOperations as h}from"@standards/schema/api";async function readInstalled(t,n){try{return await t.get(n)}catch(t){if(t instanceof e&&t.status===404)return null;throw t}}async function syncBundle(t,r,a={}){let o=await r.build(),s=u(d.sync,{name:o.name}),c=await readInstalled(t,s);if(c?.hash===o.hash&&c.label===o.label&&c.description===o.description&&c.uses.join(`
3
+ `)===o.uses.join(`
4
+ `))return{applied:!1,hash:o.hash};let l=a.resolutions&&a.resolutions.length>0?{...o,resolutions:a.resolutions}:o;try{return await t.put(s,l)}catch(t){throw t instanceof e&&t.status===409?new i(t.status,t.message,t.code):t instanceof e&&t.status===400?new n(t.status,t.message,t.code):t}}function assertTimeout(e){if(e!==void 0&&!(Number.isFinite(e)&&e>0))throw new l(`timeoutMs must be a positive number of milliseconds`,[{path:[`timeoutMs`],message:`Expected a positive, finite number`}])}function assertFileInput(e,t){if(!(e instanceof Blob))throw new l(`${t} must be a Blob or File`,[{path:[t],message:`Expected a Blob or File`}]);let n=e.name;if(typeof n!=`string`||n===``)throw new l(`${t} needs a filename`,[{path:[t,`name`],message:`Expected a non-empty filename`}]);if(e.type===``)throw new l(`${t} "${n}" needs a MIME type`,[{path:[t,`type`],message:`Expected a non-empty MIME type`}])}function reviveDocumentFile(e){return{...e,processedAt:e.processedAt===null?null:new Date(e.processedAt)}}function createDocumentsApi(e){async function attachToRecord(t){let{file:n}=t;assertFileInput(n,`file`),assertTimeout(t.timeoutMs);let r=u(h.attachDocument,{objectName:t.objectName,id:t.recordId}),i=new FormData;i.append(`files`,n,n.name),t.attributeName!==void 0&&i.append(`attributeName`,t.attributeName),t.documentId!==void 0&&i.append(`documentId`,t.documentId),t.title!==void 0&&i.append(`title`,t.title);let a=await e.postMultipart(r,i,{timeoutMs:t.timeoutMs});return{document:{id:a.document.id,title:a.document.title},file:reviveDocumentFile(a.file),action:a.action}}async function listFiles(t){return(await e.get(u(f.files,{id:t}))).map(reviveDocumentFile)}return{attachToRecord,listFiles}}function toUploadedFile(e){let t={id:e.id,name:e.name,mimeType:e.mimeType,size:e.size};return e.isPublic===!0&&typeof e.publicUrl==`string`?{...t,isPublic:!0,publicUrl:e.publicUrl}:{...t,isPublic:!1}}function createFilesApi(e){async function upload(t){assertFileInput(t.file,`file`),assertTimeout(t.timeoutMs);let[n]=await e.call(p.upload,{files:[t.file],public:t.public===!0?`true`:`false`,folderPath:t.folderPath},{timeoutMs:t.timeoutMs});return toUploadedFile(n)}async function getDownloadUrl(t){let{url:n}=await e.call(p.signedUrl,{id:t});return n}return{upload,getDownloadUrl}}function objectKeyOf(e){return e.replace(/-([a-z0-9])/g,(e,t)=>t.toUpperCase())}const g=new Set([`from`,`files`,`documents`,`bundles`]);function assertObjectKeys(e){let n=new Map;for(let r of e){if(r.includes(`--`)||r.endsWith(`-`))throw new t(`Object "${r}" has a doubled or trailing hyphen, which has no client key. Rename the object.`);let e=objectKeyOf(r);if(g.has(e))throw new t(`Object "${r}" maps to the client key "${e}", which is reserved. Rename the object.`);let i=n.get(e);if(i!==void 0&&i!==r)throw new t(`Objects "${i}" and "${r}" both map to the client key "${e}". Rename one of them.`);n.set(e,r)}}function assertObjectNames(e){let t=new Set;for(let n of e){if(t.has(n))throw new o(`object`,n);t.add(n)}assertObjectKeys(e)}const _=[`createdAt`,`updatedAt`,`deletedAt`];function dateAttributeNames(e){let t=new Set;for(let n of e?.attributes??[])n.type===`date`&&t.add(n.name);return t}function isRange(e){return typeof e==`object`&&!!e&&`start`in e&&`end`in e}function isRecord(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function flattenValues(e){let{values:t,...n}=e;return{...n,...isRecord(t)?t:{}}}function toDate(e){return typeof e==`string`?new Date(e):isRange(e)?{start:toDate(e.start),end:toDate(e.end)}:e}function reviveRecord(e,t){let n=dateAttributeNames(e),r=flattenValues(t);for(let e of _)e in r&&(r[e]=toDate(r[e]));for(let e of n)e in r&&(r[e]=toDate(r[e]));return r}function serializeInput(e){return Object.fromEntries(Object.entries(e).map(([e,t])=>[e,t instanceof Date?t.toISOString():t]))}var v=class RecordsQueryImpl extends s{constructor(e,t,n,r={object:t,combinator:`and`,rules:[],sorts:[]}){super(r),this.transport=e,this.objectName=t,this.definition=n}with(e){return new RecordsQueryImpl(this.transport,this.objectName,this.definition,{...this.state,...e})}body(){let e={};return this.state.search!==void 0&&(e.q=this.state.search),this.state.rules.length>0&&(e.filters={combinator:this.state.combinator,rules:this.state.rules}),this.state.sorts.length>0&&(e.sorts=this.state.sorts),this.state.limit!==void 0&&(e.limit=this.state.limit),this.state.offset!==void 0&&(e.offset=this.state.offset),e}revive(e){return reviveRecord(this.definition,e)}async export(e,n={}){if(!this.transport.postRaw)throw new t(`export() needs a transport with postRaw(path, body): Promise<Response>`);let{filters:r,sorts:i}=this.body(),{ids:a,locale:o,filename:s}=n;return await this.transport.postRaw(u(h.export,{objectName:this.objectName}),{q:this.state.search??``,...r?{filters:r}:{},...i?{sorts:i}:{},columns:e,...a?{ids:a}:{},...o?{locale:o}:{},timezone:n.timezone??Intl.DateTimeFormat().resolvedOptions().timeZone,...s?{filename:s}:{}})}async aggregate(e){if(this.state.search!==void 0)throw new a(c.AGGREGATE_SEARCH_UNSUPPORTED,`An aggregate cannot be narrowed by a search; use filters instead`);let t={...e,query:this.toDefinition(),timezone:e.timezone??Intl.DateTimeFormat().resolvedOptions().timeZone};return await this.transport.post(u(h.aggregate,{objectName:this.objectName}),t)}async fetchPage(){let e=this.state.search===void 0?`list`:`search`,t=await this.transport.post(u(h[e],{objectName:this.objectName}),this.body());return{records:t.data.map(e=>this.revive(e)),page:t.page}}async fetch(){let{records:e,page:t}=await this.fetchPage();return{records:e,total:t.total}}async all(){if(this.state.limit!==void 0&&this.state.limit<0)return(await this.fetch()).records;let e=this.state.limit??1/0,t=[],n=this.state.offset??0;for(;;){let r=Math.min(1e3,e-t.length);if(r<=0)return t;let{records:i,page:a}=await this.with({limit:r,offset:n}).fetchPage();if(t.push(...i),!a.hasMore)return t;let o=a.nextOffset??n+i.length;if(o<=n)return t;n=o}}async single(){let{records:e}=await this.limit(1).fetch();return e[0]??null}async get(e){let t=await this.transport.get(u(h.get,{objectName:this.objectName,id:e}));return this.revive(t)}async create(e){let t=await this.transport.post(u(h.create,{objectName:this.objectName}),{data:serializeInput(e)});return this.revive(t)}async update(e,t){let n=await this.transport.put(u(h.update,{objectName:this.objectName,id:e}),serializeInput(t));return this.revive(n)}async delete(e){await this.transport.delete(u(h.delete,{objectName:this.objectName,id:e}))}async inChunks(e,t){for(let n=0;n<e.length;n+=100)await t(e.slice(n,n+100),n)}async createMany(e){let t={created:[],errors:[]};return await this.inChunks(e,async(e,n)=>{let r=await this.transport.post(u(h.bulkCreate,{objectName:this.objectName}),{records:e.map(serializeInput)});t.created.push(...r.created.map(e=>this.revive(e))),t.errors.push(...r.errors.map(e=>({...e,index:e.index+n})))}),t}async updateMany(e){let t={updated:[],errors:[]};return await this.inChunks(e,async e=>{let n=await this.transport.post(u(h.bulkUpdate,{objectName:this.objectName}),{updates:e.map(({id:e,data:t})=>({id:e,data:serializeInput(t)}))});t.updated.push(...n.updated.map(e=>this.revive(e))),t.errors.push(...n.errors)}),t}async deleteMany(e){let t={deleted:[],errors:[]};return await this.inChunks(e,async e=>{let n=await this.transport.post(u(h.bulkDelete,{objectName:this.objectName}),{ids:e});t.deleted.push(...n.deleted),t.errors.push(...n.errors)}),t}async listAccess(e){return await this.transport.get(u(m.list,{objectName:this.objectName,recordId:e}))}async grantAccess(e,t,n){return await this.transport.put(u(m.grant,{objectName:this.objectName,recordId:e,actorId:t}),{role:n})}async revokeAccess(e,t){return await this.transport.delete(u(m.revoke,{objectName:this.objectName,recordId:e,actorId:t}))}async clearAccess(e){return await this.transport.delete(u(m.clear,{objectName:this.objectName,recordId:e}))}};const y=new WeakMap;function definitionOf(e){let t=y.get(e);if(t)return t;let n=e.build();return y.set(e,n),n}function createRecordsQuery(e,t){if(typeof t==`string`)return new v(e,t,null);let n=definitionOf(t);return new v(e,n.name,n)}function readEnvironment(){return typeof process>`u`||!process.env?{}:{baseUrl:process.env.STANDARDS_API_URL||void 0,apiKey:process.env.STANDARDS_API_KEY||void 0}}function resolveConfig(e){if(globalThis.window!==void 0){if(e.apiKey)throw new t(`createStandards received an apiKey in a browser context. API keys belong to server code only (Route Handlers, Server Components, scripts).`);if(e.baseUrl===void 0)throw new t(`createStandards needs an explicit baseUrl in a browser context: STANDARDS_API_URL and STANDARDS_API_KEY are never read from the environment there.`);return{...e,baseUrl:e.baseUrl,apiKey:``}}let n=readEnvironment(),r=e.baseUrl??n.baseUrl;if(r===void 0)throw new t(`createStandards needs a base URL: pass baseUrl or set the STANDARDS_API_URL environment variable.`);let i=e.apiKey??n.apiKey;if(i===void 0)throw new t(`createStandards needs an API key: pass apiKey or set the STANDARDS_API_KEY environment variable.`);return{...e,baseUrl:r,apiKey:i}}function createStandards(e={}){let{bundles:t=[],...n}=e;return buildStandards(r(resolveConfig(n)),t.flatMap(e=>e.objectBuilders))}function buildStandards(e,t){let n={bundles:{sync:(t,n)=>syncBundle(e,t,n)},from:t=>createRecordsQuery(e,t),files:createFilesApi(e),documents:createDocumentsApi(e)},r=t.map(e=>definitionOf(e).name);return assertObjectNames(r),t.forEach((t,i)=>{n[objectKeyOf(r[i])]=createRecordsQuery(e,t)}),n}export{reviveRecord as a,createDocumentsApi as c,definitionOf as i,syncBundle as l,createStandards as n,serializeInput as o,createRecordsQuery as r,createFilesApi as s,buildStandards as t};
@@ -0,0 +1,4 @@
1
+ /*! © 2025-2026 AND YOU CREATE SAS (RCS Paris 940 190 614). Proprietary — see LICENSE (Standards SDK License 1.0). */
2
+ const e=require("./http-transport-CAPVZuiv.js");let t=require("@standards/schema"),n=require("@standards/schema/api");async function readInstalled(t,n){try{return await t.get(n)}catch(t){if(t instanceof e._&&t.status===404)return null;throw t}}async function syncBundle(t,r,i={}){let a=await r.build(),o=(0,n.buildOperationPath)(n.bundlesOperations.sync,{name:a.name}),s=await readInstalled(t,o);if(s?.hash===a.hash&&s.label===a.label&&s.description===a.description&&s.uses.join(`
3
+ `)===a.uses.join(`
4
+ `))return{applied:!1,hash:a.hash};let c=i.resolutions&&i.resolutions.length>0?{...a,resolutions:i.resolutions}:a;try{return await t.put(o,c)}catch(t){throw t instanceof e._&&t.status===409?new e.p(t.status,t.message,t.code):t instanceof e._&&t.status===400?new e.m(t.status,t.message,t.code):t}}function assertTimeout(e){if(e!==void 0&&!(Number.isFinite(e)&&e>0))throw new t.ValidationError(`timeoutMs must be a positive number of milliseconds`,[{path:[`timeoutMs`],message:`Expected a positive, finite number`}])}function assertFileInput(e,n){if(!(e instanceof Blob))throw new t.ValidationError(`${n} must be a Blob or File`,[{path:[n],message:`Expected a Blob or File`}]);let r=e.name;if(typeof r!=`string`||r===``)throw new t.ValidationError(`${n} needs a filename`,[{path:[n,`name`],message:`Expected a non-empty filename`}]);if(e.type===``)throw new t.ValidationError(`${n} "${r}" needs a MIME type`,[{path:[n,`type`],message:`Expected a non-empty MIME type`}])}function reviveDocumentFile(e){return{...e,processedAt:e.processedAt===null?null:new Date(e.processedAt)}}function createDocumentsApi(e){async function attachToRecord(t){let{file:r}=t;assertFileInput(r,`file`),assertTimeout(t.timeoutMs);let i=(0,n.buildOperationPath)(n.recordsOperations.attachDocument,{objectName:t.objectName,id:t.recordId}),a=new FormData;a.append(`files`,r,r.name),t.attributeName!==void 0&&a.append(`attributeName`,t.attributeName),t.documentId!==void 0&&a.append(`documentId`,t.documentId),t.title!==void 0&&a.append(`title`,t.title);let o=await e.postMultipart(i,a,{timeoutMs:t.timeoutMs});return{document:{id:o.document.id,title:o.document.title},file:reviveDocumentFile(o.file),action:o.action}}async function listFiles(t){return(await e.get((0,n.buildOperationPath)(n.documentsOperations.files,{id:t}))).map(reviveDocumentFile)}return{attachToRecord,listFiles}}function toUploadedFile(e){let t={id:e.id,name:e.name,mimeType:e.mimeType,size:e.size};return e.isPublic===!0&&typeof e.publicUrl==`string`?{...t,isPublic:!0,publicUrl:e.publicUrl}:{...t,isPublic:!1}}function createFilesApi(e){async function upload(t){assertFileInput(t.file,`file`),assertTimeout(t.timeoutMs);let[r]=await e.call(n.filesOperations.upload,{files:[t.file],public:t.public===!0?`true`:`false`,folderPath:t.folderPath},{timeoutMs:t.timeoutMs});return toUploadedFile(r)}async function getDownloadUrl(t){let{url:r}=await e.call(n.filesOperations.signedUrl,{id:t});return r}return{upload,getDownloadUrl}}function objectKeyOf(e){return e.replace(/-([a-z0-9])/g,(e,t)=>t.toUpperCase())}const r=new Set([`from`,`files`,`documents`,`bundles`]);function assertObjectKeys(t){let n=new Map;for(let i of t){if(i.includes(`--`)||i.endsWith(`-`))throw new e.g(`Object "${i}" has a doubled or trailing hyphen, which has no client key. Rename the object.`);let t=objectKeyOf(i);if(r.has(t))throw new e.g(`Object "${i}" maps to the client key "${t}", which is reserved. Rename the object.`);let a=n.get(t);if(a!==void 0&&a!==i)throw new e.g(`Objects "${a}" and "${i}" both map to the client key "${t}". Rename one of them.`);n.set(t,i)}}function assertObjectNames(e){let n=new Set;for(let r of e){if(n.has(r))throw new t.DuplicateError(`object`,r);n.add(r)}assertObjectKeys(e)}const i=[`createdAt`,`updatedAt`,`deletedAt`];function dateAttributeNames(e){let t=new Set;for(let n of e?.attributes??[])n.type===`date`&&t.add(n.name);return t}function isRange(e){return typeof e==`object`&&!!e&&`start`in e&&`end`in e}function isRecord(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function flattenValues(e){let{values:t,...n}=e;return{...n,...isRecord(t)?t:{}}}function toDate(e){return typeof e==`string`?new Date(e):isRange(e)?{start:toDate(e.start),end:toDate(e.end)}:e}function reviveRecord(e,t){let n=dateAttributeNames(e),r=flattenValues(t);for(let e of i)e in r&&(r[e]=toDate(r[e]));for(let e of n)e in r&&(r[e]=toDate(r[e]));return r}function serializeInput(e){return Object.fromEntries(Object.entries(e).map(([e,t])=>[e,t instanceof Date?t.toISOString():t]))}var a=class RecordsQueryImpl extends t.RecordQuery{constructor(e,t,n,r={object:t,combinator:`and`,rules:[],sorts:[]}){super(r),this.transport=e,this.objectName=t,this.definition=n}with(e){return new RecordsQueryImpl(this.transport,this.objectName,this.definition,{...this.state,...e})}body(){let e={};return this.state.search!==void 0&&(e.q=this.state.search),this.state.rules.length>0&&(e.filters={combinator:this.state.combinator,rules:this.state.rules}),this.state.sorts.length>0&&(e.sorts=this.state.sorts),this.state.limit!==void 0&&(e.limit=this.state.limit),this.state.offset!==void 0&&(e.offset=this.state.offset),e}revive(e){return reviveRecord(this.definition,e)}async export(t,r={}){if(!this.transport.postRaw)throw new e.g(`export() needs a transport with postRaw(path, body): Promise<Response>`);let{filters:i,sorts:a}=this.body(),{ids:o,locale:s,filename:c}=r;return await this.transport.postRaw((0,n.buildOperationPath)(n.recordsOperations.export,{objectName:this.objectName}),{q:this.state.search??``,...i?{filters:i}:{},...a?{sorts:a}:{},columns:t,...o?{ids:o}:{},...s?{locale:s}:{},timezone:r.timezone??Intl.DateTimeFormat().resolvedOptions().timeZone,...c?{filename:c}:{}})}async aggregate(e){if(this.state.search!==void 0)throw new t.AggregateValidationError(t.SchemaErrorCode.AGGREGATE_SEARCH_UNSUPPORTED,`An aggregate cannot be narrowed by a search; use filters instead`);let r={...e,query:this.toDefinition(),timezone:e.timezone??Intl.DateTimeFormat().resolvedOptions().timeZone};return await this.transport.post((0,n.buildOperationPath)(n.recordsOperations.aggregate,{objectName:this.objectName}),r)}async fetchPage(){let e=this.state.search===void 0?`list`:`search`,t=await this.transport.post((0,n.buildOperationPath)(n.recordsOperations[e],{objectName:this.objectName}),this.body());return{records:t.data.map(e=>this.revive(e)),page:t.page}}async fetch(){let{records:e,page:t}=await this.fetchPage();return{records:e,total:t.total}}async all(){if(this.state.limit!==void 0&&this.state.limit<0)return(await this.fetch()).records;let e=this.state.limit??1/0,t=[],n=this.state.offset??0;for(;;){let r=Math.min(1e3,e-t.length);if(r<=0)return t;let{records:i,page:a}=await this.with({limit:r,offset:n}).fetchPage();if(t.push(...i),!a.hasMore)return t;let o=a.nextOffset??n+i.length;if(o<=n)return t;n=o}}async single(){let{records:e}=await this.limit(1).fetch();return e[0]??null}async get(e){let t=await this.transport.get((0,n.buildOperationPath)(n.recordsOperations.get,{objectName:this.objectName,id:e}));return this.revive(t)}async create(e){let t=await this.transport.post((0,n.buildOperationPath)(n.recordsOperations.create,{objectName:this.objectName}),{data:serializeInput(e)});return this.revive(t)}async update(e,t){let r=await this.transport.put((0,n.buildOperationPath)(n.recordsOperations.update,{objectName:this.objectName,id:e}),serializeInput(t));return this.revive(r)}async delete(e){await this.transport.delete((0,n.buildOperationPath)(n.recordsOperations.delete,{objectName:this.objectName,id:e}))}async inChunks(e,t){for(let n=0;n<e.length;n+=100)await t(e.slice(n,n+100),n)}async createMany(e){let t={created:[],errors:[]};return await this.inChunks(e,async(e,r)=>{let i=await this.transport.post((0,n.buildOperationPath)(n.recordsOperations.bulkCreate,{objectName:this.objectName}),{records:e.map(serializeInput)});t.created.push(...i.created.map(e=>this.revive(e))),t.errors.push(...i.errors.map(e=>({...e,index:e.index+r})))}),t}async updateMany(e){let t={updated:[],errors:[]};return await this.inChunks(e,async e=>{let r=await this.transport.post((0,n.buildOperationPath)(n.recordsOperations.bulkUpdate,{objectName:this.objectName}),{updates:e.map(({id:e,data:t})=>({id:e,data:serializeInput(t)}))});t.updated.push(...r.updated.map(e=>this.revive(e))),t.errors.push(...r.errors)}),t}async deleteMany(e){let t={deleted:[],errors:[]};return await this.inChunks(e,async e=>{let r=await this.transport.post((0,n.buildOperationPath)(n.recordsOperations.bulkDelete,{objectName:this.objectName}),{ids:e});t.deleted.push(...r.deleted),t.errors.push(...r.errors)}),t}async listAccess(e){return await this.transport.get((0,n.buildOperationPath)(n.recordAccessOperations.list,{objectName:this.objectName,recordId:e}))}async grantAccess(e,t,r){return await this.transport.put((0,n.buildOperationPath)(n.recordAccessOperations.grant,{objectName:this.objectName,recordId:e,actorId:t}),{role:r})}async revokeAccess(e,t){return await this.transport.delete((0,n.buildOperationPath)(n.recordAccessOperations.revoke,{objectName:this.objectName,recordId:e,actorId:t}))}async clearAccess(e){return await this.transport.delete((0,n.buildOperationPath)(n.recordAccessOperations.clear,{objectName:this.objectName,recordId:e}))}};const o=new WeakMap;function definitionOf(e){let t=o.get(e);if(t)return t;let n=e.build();return o.set(e,n),n}function createRecordsQuery(e,t){if(typeof t==`string`)return new a(e,t,null);let n=definitionOf(t);return new a(e,n.name,n)}function readEnvironment(){return typeof process>`u`||!process.env?{}:{baseUrl:process.env.STANDARDS_API_URL||void 0,apiKey:process.env.STANDARDS_API_KEY||void 0}}function resolveConfig(t){if(globalThis.window!==void 0){if(t.apiKey)throw new e.g(`createStandards received an apiKey in a browser context. API keys belong to server code only (Route Handlers, Server Components, scripts).`);if(t.baseUrl===void 0)throw new e.g(`createStandards needs an explicit baseUrl in a browser context: STANDARDS_API_URL and STANDARDS_API_KEY are never read from the environment there.`);return{...t,baseUrl:t.baseUrl,apiKey:``}}let n=readEnvironment(),r=t.baseUrl??n.baseUrl;if(r===void 0)throw new e.g(`createStandards needs a base URL: pass baseUrl or set the STANDARDS_API_URL environment variable.`);let i=t.apiKey??n.apiKey;if(i===void 0)throw new e.g(`createStandards needs an API key: pass apiKey or set the STANDARDS_API_KEY environment variable.`);return{...t,baseUrl:r,apiKey:i}}function createStandards(t={}){let{bundles:n=[],...r}=t;return buildStandards(e.n(resolveConfig(r)),n.flatMap(e=>e.objectBuilders))}function buildStandards(e,t){let n={bundles:{sync:(t,n)=>syncBundle(e,t,n)},from:t=>createRecordsQuery(e,t),files:createFilesApi(e),documents:createDocumentsApi(e)},r=t.map(e=>definitionOf(e).name);return assertObjectNames(r),t.forEach((t,i)=>{n[objectKeyOf(r[i])]=createRecordsQuery(e,t)}),n}Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return reviveRecord}}),Object.defineProperty(exports,"c",{enumerable:!0,get:function(){return createDocumentsApi}}),Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return definitionOf}}),Object.defineProperty(exports,"l",{enumerable:!0,get:function(){return syncBundle}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return createStandards}}),Object.defineProperty(exports,"o",{enumerable:!0,get:function(){return serializeInput}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return createRecordsQuery}}),Object.defineProperty(exports,"s",{enumerable:!0,get:function(){return createFilesApi}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return buildStandards}});
@@ -1,57 +1,29 @@
1
1
 
2
- import { r as MultipartRequestOptions, s as TransportConfig, t as HttpTransport } from "./http-transport-DBgedLFQ.js";
3
- import { AggregateRecordsOptions, ContentViewDefinition, DocumentFile, ExtractRecord, ExtractRecordInputStrict, ExtractRecordUpdateStrict, FilterRule, ObjectBuilderLike, ObjectBuilderLike as ObjectBuilderLike$1, ObjectDefinition, RecordAccessRole, RecordAggregates, RecordAudience, RuleValue, SchemaGroupPresentation, SchemaSourceResolution, ViewDeclaration } from "@standards/schema";
4
- //#region src/define-schema-source.d.ts
2
+ import { r as MultipartRequestOptions, s as TransportConfig, t as HttpTransport } from "./http-transport-C1u5UGkC.mjs";
3
+ import { AggregateRecordsOptions, BundleBuilder, DocumentFile, ExtractRecord, ExtractRecordInputStrict, ExtractRecordUpdateStrict, FilterRule, ObjectBuilderLike, ObjectDefinition, RecordAccessRole, RecordAggregates, RecordAudience, RuleValue, SchemaSourceResolution, SyncBundleResult } from "@standards/schema";
4
+ //#region src/bundle-sync.d.ts
5
5
  /**
6
- * `@standards/constants` (the home of `IconName`) is not a dependency of this
7
- * package; deriving the type from `SchemaGroupPresentation` avoids adding one
8
- * just for a type alias.
6
+ * What a sync carries besides the bundle itself.
7
+ *
8
+ * `resolutions` resolve the renames and retypes the server refuses as
9
+ * ambiguous (`SCHEMA_AMBIGUOUS_CHANGE`), which names the exact entries to
10
+ * send. They travel outside the hash: a bundle whose hash the workspace
11
+ * already holds is not pushed, and the resolutions with it.
9
12
  */
10
- type IconName = NonNullable<SchemaGroupPresentation["icon"]>;
11
- type ViewInput = ContentViewDefinition | ViewDeclaration | {
12
- build(): ContentViewDefinition | ViewDeclaration;
13
- };
14
- interface SchemaSourceConfig<TObjects extends readonly ObjectBuilderLike[]> {
15
- /**
16
- * Slug identity of the source, required to sync. Write it by hand, or derive
17
- * it with `sourceIdFromPackageName(packageJson.name)`.
18
- */
19
- id?: string;
20
- objects: TObjects;
21
- views?: ViewInput[];
22
- label?: string;
23
- icon?: IconName;
24
- }
25
- /** What `defineSchemaSource` returns: the declaration only — nothing is built until it is resolved. */
26
- interface SchemaSource<TObjects extends readonly ObjectBuilderLike[] = readonly ObjectBuilderLike[]> {
27
- readonly id: string | null;
28
- /** The builders, kept for type inference of the typed client (`db.<camelCaseName>`). */
29
- readonly builders: TObjects;
30
- readonly views: readonly ViewInput[];
31
- readonly label: string | null;
32
- readonly icon: IconName | null;
13
+ interface SyncBundleOptions {
14
+ resolutions?: SchemaSourceResolution[];
33
15
  }
34
- /** A source built, validated and hashed — what a sync sends. */
35
- interface ResolvedSchemaSource {
36
- id: string | null;
37
- /** sha256 hex of `canonicalStringify({ objects, views })` — the same digest the server recomputes. */
38
- hash: string;
39
- objects: ObjectDefinition[];
40
- views: ContentViewDefinition[];
41
- label: string | null;
42
- icon: IconName | null;
16
+ /**
17
+ * The two verbs a sync needs, typed non-generically: the real `Transport`
18
+ * satisfies it, and so does a hand-rolled stub, which a `Pick` of the generic
19
+ * signatures would reject.
20
+ */
21
+ interface SyncTransport {
22
+ get(path: string): Promise<unknown>;
23
+ put(path: string, body?: unknown): Promise<unknown>;
43
24
  }
44
- /** sha256 hex over the canonical JSON, with Web Crypto (Node >= 20, Edge, browsers). */
45
- declare function hashSchemaSource(payload: {
46
- objects: ObjectDefinition[];
47
- views: ContentViewDefinition[];
48
- }): Promise<string>;
49
- /** Declares the schema an external codebase owns. Does no work: see `resolveSchemaSource`. */
50
- declare function defineSchemaSource<const TObjects extends readonly ObjectBuilderLike[]>(config: SchemaSourceConfig<TObjects>): SchemaSource<TObjects>;
51
- /** Builds, validates and hashes a source once; later calls share the same promise. */
52
- declare function resolveSchemaSource(source: SchemaSource): Promise<ResolvedSchemaSource>;
53
- /** `@acme/crm` -> `acme-crm`; refuses a name the server would refuse as a source id. */
54
- declare function sourceIdFromPackageName(packageName: string): string;
25
+ /** GET the installed summary; PUT the built bundle when its hash, label, description or uses differ, or it was never synced. */
26
+ declare function syncBundle(transport: SyncTransport, bundle: BundleBuilder<string, readonly ObjectBuilderLike[]>, options?: SyncBundleOptions): Promise<SyncBundleResult>;
55
27
  //#endregion
56
28
  //#region src/files/file-input.d.ts
57
29
  /**
@@ -353,70 +325,25 @@ interface RecordsTransport {
353
325
  delete(path: string): Promise<unknown>;
354
326
  }
355
327
  /** A builder gives typed records; a bare object name is the untyped escape hatch. */
356
- declare function createRecordsQuery<TBuilder extends ObjectBuilderLike$1>(transport: RecordsTransport, target: TBuilder): RecordsQuery<TBuilder>;
328
+ declare function createRecordsQuery<TBuilder extends ObjectBuilderLike>(transport: RecordsTransport, target: TBuilder): RecordsQuery<TBuilder>;
357
329
  declare function createRecordsQuery(transport: RecordsTransport, target: string): UntypedRecordsQuery;
358
330
  //#endregion
359
- //#region src/schema-sync.d.ts
360
- interface SchemaSourceSummary {
361
- sourceId: string;
362
- hash: string;
363
- appliedAt: string;
364
- objectNames: string[];
365
- /** Absent on an older server that predates presentation; treated as "no presentation". */
366
- label?: string | null;
367
- icon?: string | null;
368
- }
369
- interface SyncResult {
370
- applied: boolean;
371
- hash: string;
372
- objects?: {
373
- created: number;
374
- updated: number;
375
- deleted: number;
376
- };
377
- views?: {
378
- created: number;
379
- updated: number;
380
- adopted: number;
381
- released: number;
382
- };
383
- }
384
- /**
385
- * What a sync carries besides the source itself.
386
- *
387
- * `resolutions` resolve the renames and retypes the server refuses as
388
- * ambiguous (`SCHEMA_AMBIGUOUS_CHANGE`), which names the exact entries to
389
- * send. They travel outside the hash: a source whose hash is already applied
390
- * is not pushed, and the resolutions with it. A server older than
391
- * `resolutions` answers 400 `Unknown source payload fields` — upgrade the
392
- * client and the server together.
393
- */
394
- interface SyncOptions {
395
- resolutions?: SchemaSourceResolution[];
396
- }
397
- /**
398
- * The two verbs a sync needs, typed non-generically: the real `Transport`
399
- * satisfies it, and so does a hand-rolled stub, which a `Pick` of the generic
400
- * signatures would reject.
401
- */
402
- interface SyncTransport {
403
- get(path: string): Promise<unknown>;
404
- put(path: string, body?: unknown): Promise<unknown>;
405
- }
406
- /** GET the remote summary; PUT when the hash or the presentation differs, or the source was never pushed. */
407
- declare function syncSchemaSource(transport: SyncTransport, declared: SchemaSource, options?: SyncOptions): Promise<SyncResult>;
408
- //#endregion
409
331
  //#region src/create-standards.d.ts
410
332
  type NameOf<B> = B extends {
411
333
  _types: {
412
334
  name: infer N extends string;
413
335
  };
414
336
  } ? N : never;
415
- /** One typed query per object of a source, keyed by the camelCase of its name. */
416
- type ObjectsOf<TObjects extends readonly ObjectBuilderLike$1[]> = { readonly [B in TObjects[number] as CamelCase<NameOf<B>>]: RecordsQuery<B>; };
337
+ /** One typed query per object, keyed by the camelCase of its name. */
338
+ type ObjectsOf<TObjects extends readonly ObjectBuilderLike[]> = { readonly [B in TObjects[number] as CamelCase<NameOf<B>>]: RecordsQuery<B>; };
339
+ /** Any bundle, whatever its name and objects. */
340
+ type AnyBundle = BundleBuilder<string, readonly ObjectBuilderLike[]>;
341
+ /** The object builders of every bundle in a tuple: what the typed client infers from. */
342
+ type ObjectsOfBundles<TBundles extends readonly AnyBundle[]> = TBundles[number]["objectBuilders"];
417
343
  interface Standards {
418
- schema: {
419
- sync(source: SchemaSource, options?: SyncOptions): Promise<SyncResult>;
344
+ bundles: {
345
+ /** Sync a bundle to the workspace; a no-op (`applied: false`) when it already holds this version. */
346
+ sync(bundle: AnyBundle, options?: SyncBundleOptions): Promise<SyncBundleResult>;
420
347
  };
421
348
  /** Untyped access to an object the code does not declare (created at runtime). */
422
349
  from(objectName: string): UntypedRecordsQuery;
@@ -431,9 +358,9 @@ interface Standards {
431
358
  * `STANDARDS_API_URL` / `STANDARDS_API_KEY`, and an explicit value always wins.
432
359
  */
433
360
  type StandardsConfig = Partial<TransportConfig>;
434
- declare function createStandards<const TObjects extends readonly ObjectBuilderLike$1[]>(config: StandardsConfig & {
435
- schema: SchemaSource<TObjects>;
436
- }): Standards & ObjectsOf<TObjects>;
361
+ declare function createStandards<const TBundles extends readonly AnyBundle[]>(config: StandardsConfig & {
362
+ bundles: TBundles;
363
+ }): Standards & ObjectsOf<ObjectsOfBundles<TBundles>>;
437
364
  declare function createStandards(config?: StandardsConfig): Standards;
438
365
  //#endregion
439
- export { UploadFileInput as A, FileInput as B, UpdateManyResult as C, FilesTransport as D, FilesApi as E, AttachToRecordInput as F, SchemaSource as G, IconName as H, AttachToRecordResult as I, defineSchemaSource as J, SchemaSourceConfig as K, DocumentsApi as L, UploadPublicFileInput as M, UploadedFile as N, PrivateUploadedFile as O, createFilesApi as P, DocumentsTransport as R, UpdateManyError as S, CamelCase as T, ObjectBuilderLike$1 as U, UploadTimeoutOption as V, ResolvedSchemaSource as W, resolveSchemaSource as X, hashSchemaSource as Y, sourceIdFromPackageName as Z, RecordsExportOptions as _, SchemaSourceSummary as a, UntypedRecordsQuery as b, syncSchemaSource as c, DeleteManyError as d, DeleteManyResult as f, RecordsAggregateOptions as g, RecordUpdate as h, createStandards as i, UploadPrivateFileInput as j, PublicUploadedFile as k, CreateManyError as l, RecordInput as m, Standards as n, SyncOptions as o, FetchResult as p, ViewInput as q, StandardsConfig as r, SyncResult as s, ObjectsOf as t, CreateManyResult as u, RecordsQuery as v, createRecordsQuery as w, UpdateManyEntry as x, UntypedBuilder as y, createDocumentsApi as z };
366
+ export { UploadPublicFileInput as A, SyncBundleOptions as B, CamelCase as C, PublicUploadedFile as D, PrivateUploadedFile as E, DocumentsApi as F, syncBundle as H, DocumentsTransport as I, createDocumentsApi as L, createFilesApi as M, AttachToRecordInput as N, UploadFileInput as O, AttachToRecordResult as P, FileInput as R, createRecordsQuery as S, FilesTransport as T, SyncTransport as V, UntypedBuilder as _, StandardsConfig as a, UpdateManyError as b, CreateManyResult as c, FetchResult as d, RecordInput as f, RecordsQuery as g, RecordsExportOptions as h, Standards as i, UploadedFile as j, UploadPrivateFileInput as k, DeleteManyError as l, RecordsAggregateOptions as m, ObjectsOf as n, createStandards as o, RecordUpdate as p, ObjectsOfBundles as r, CreateManyError as s, AnyBundle as t, DeleteManyResult as u, UntypedRecordsQuery as v, FilesApi as w, UpdateManyResult as x, UpdateManyEntry as y, UploadTimeoutOption as z };
@@ -1,57 +1,29 @@
1
1
 
2
- import { r as MultipartRequestOptions, s as TransportConfig, t as HttpTransport } from "./http-transport-DBgedLFQ.mjs";
3
- import { AggregateRecordsOptions, ContentViewDefinition, DocumentFile, ExtractRecord, ExtractRecordInputStrict, ExtractRecordUpdateStrict, FilterRule, ObjectBuilderLike, ObjectBuilderLike as ObjectBuilderLike$1, ObjectDefinition, RecordAccessRole, RecordAggregates, RecordAudience, RuleValue, SchemaGroupPresentation, SchemaSourceResolution, ViewDeclaration } from "@standards/schema";
4
- //#region src/define-schema-source.d.ts
2
+ import { r as MultipartRequestOptions, s as TransportConfig, t as HttpTransport } from "./http-transport-C1u5UGkC.js";
3
+ import { AggregateRecordsOptions, BundleBuilder, DocumentFile, ExtractRecord, ExtractRecordInputStrict, ExtractRecordUpdateStrict, FilterRule, ObjectBuilderLike, ObjectDefinition, RecordAccessRole, RecordAggregates, RecordAudience, RuleValue, SchemaSourceResolution, SyncBundleResult } from "@standards/schema";
4
+ //#region src/bundle-sync.d.ts
5
5
  /**
6
- * `@standards/constants` (the home of `IconName`) is not a dependency of this
7
- * package; deriving the type from `SchemaGroupPresentation` avoids adding one
8
- * just for a type alias.
6
+ * What a sync carries besides the bundle itself.
7
+ *
8
+ * `resolutions` resolve the renames and retypes the server refuses as
9
+ * ambiguous (`SCHEMA_AMBIGUOUS_CHANGE`), which names the exact entries to
10
+ * send. They travel outside the hash: a bundle whose hash the workspace
11
+ * already holds is not pushed, and the resolutions with it.
9
12
  */
10
- type IconName = NonNullable<SchemaGroupPresentation["icon"]>;
11
- type ViewInput = ContentViewDefinition | ViewDeclaration | {
12
- build(): ContentViewDefinition | ViewDeclaration;
13
- };
14
- interface SchemaSourceConfig<TObjects extends readonly ObjectBuilderLike[]> {
15
- /**
16
- * Slug identity of the source, required to sync. Write it by hand, or derive
17
- * it with `sourceIdFromPackageName(packageJson.name)`.
18
- */
19
- id?: string;
20
- objects: TObjects;
21
- views?: ViewInput[];
22
- label?: string;
23
- icon?: IconName;
24
- }
25
- /** What `defineSchemaSource` returns: the declaration only — nothing is built until it is resolved. */
26
- interface SchemaSource<TObjects extends readonly ObjectBuilderLike[] = readonly ObjectBuilderLike[]> {
27
- readonly id: string | null;
28
- /** The builders, kept for type inference of the typed client (`db.<camelCaseName>`). */
29
- readonly builders: TObjects;
30
- readonly views: readonly ViewInput[];
31
- readonly label: string | null;
32
- readonly icon: IconName | null;
13
+ interface SyncBundleOptions {
14
+ resolutions?: SchemaSourceResolution[];
33
15
  }
34
- /** A source built, validated and hashed — what a sync sends. */
35
- interface ResolvedSchemaSource {
36
- id: string | null;
37
- /** sha256 hex of `canonicalStringify({ objects, views })` — the same digest the server recomputes. */
38
- hash: string;
39
- objects: ObjectDefinition[];
40
- views: ContentViewDefinition[];
41
- label: string | null;
42
- icon: IconName | null;
16
+ /**
17
+ * The two verbs a sync needs, typed non-generically: the real `Transport`
18
+ * satisfies it, and so does a hand-rolled stub, which a `Pick` of the generic
19
+ * signatures would reject.
20
+ */
21
+ interface SyncTransport {
22
+ get(path: string): Promise<unknown>;
23
+ put(path: string, body?: unknown): Promise<unknown>;
43
24
  }
44
- /** sha256 hex over the canonical JSON, with Web Crypto (Node >= 20, Edge, browsers). */
45
- declare function hashSchemaSource(payload: {
46
- objects: ObjectDefinition[];
47
- views: ContentViewDefinition[];
48
- }): Promise<string>;
49
- /** Declares the schema an external codebase owns. Does no work: see `resolveSchemaSource`. */
50
- declare function defineSchemaSource<const TObjects extends readonly ObjectBuilderLike[]>(config: SchemaSourceConfig<TObjects>): SchemaSource<TObjects>;
51
- /** Builds, validates and hashes a source once; later calls share the same promise. */
52
- declare function resolveSchemaSource(source: SchemaSource): Promise<ResolvedSchemaSource>;
53
- /** `@acme/crm` -> `acme-crm`; refuses a name the server would refuse as a source id. */
54
- declare function sourceIdFromPackageName(packageName: string): string;
25
+ /** GET the installed summary; PUT the built bundle when its hash, label, description or uses differ, or it was never synced. */
26
+ declare function syncBundle(transport: SyncTransport, bundle: BundleBuilder<string, readonly ObjectBuilderLike[]>, options?: SyncBundleOptions): Promise<SyncBundleResult>;
55
27
  //#endregion
56
28
  //#region src/files/file-input.d.ts
57
29
  /**
@@ -353,70 +325,25 @@ interface RecordsTransport {
353
325
  delete(path: string): Promise<unknown>;
354
326
  }
355
327
  /** A builder gives typed records; a bare object name is the untyped escape hatch. */
356
- declare function createRecordsQuery<TBuilder extends ObjectBuilderLike$1>(transport: RecordsTransport, target: TBuilder): RecordsQuery<TBuilder>;
328
+ declare function createRecordsQuery<TBuilder extends ObjectBuilderLike>(transport: RecordsTransport, target: TBuilder): RecordsQuery<TBuilder>;
357
329
  declare function createRecordsQuery(transport: RecordsTransport, target: string): UntypedRecordsQuery;
358
330
  //#endregion
359
- //#region src/schema-sync.d.ts
360
- interface SchemaSourceSummary {
361
- sourceId: string;
362
- hash: string;
363
- appliedAt: string;
364
- objectNames: string[];
365
- /** Absent on an older server that predates presentation; treated as "no presentation". */
366
- label?: string | null;
367
- icon?: string | null;
368
- }
369
- interface SyncResult {
370
- applied: boolean;
371
- hash: string;
372
- objects?: {
373
- created: number;
374
- updated: number;
375
- deleted: number;
376
- };
377
- views?: {
378
- created: number;
379
- updated: number;
380
- adopted: number;
381
- released: number;
382
- };
383
- }
384
- /**
385
- * What a sync carries besides the source itself.
386
- *
387
- * `resolutions` resolve the renames and retypes the server refuses as
388
- * ambiguous (`SCHEMA_AMBIGUOUS_CHANGE`), which names the exact entries to
389
- * send. They travel outside the hash: a source whose hash is already applied
390
- * is not pushed, and the resolutions with it. A server older than
391
- * `resolutions` answers 400 `Unknown source payload fields` — upgrade the
392
- * client and the server together.
393
- */
394
- interface SyncOptions {
395
- resolutions?: SchemaSourceResolution[];
396
- }
397
- /**
398
- * The two verbs a sync needs, typed non-generically: the real `Transport`
399
- * satisfies it, and so does a hand-rolled stub, which a `Pick` of the generic
400
- * signatures would reject.
401
- */
402
- interface SyncTransport {
403
- get(path: string): Promise<unknown>;
404
- put(path: string, body?: unknown): Promise<unknown>;
405
- }
406
- /** GET the remote summary; PUT when the hash or the presentation differs, or the source was never pushed. */
407
- declare function syncSchemaSource(transport: SyncTransport, declared: SchemaSource, options?: SyncOptions): Promise<SyncResult>;
408
- //#endregion
409
331
  //#region src/create-standards.d.ts
410
332
  type NameOf<B> = B extends {
411
333
  _types: {
412
334
  name: infer N extends string;
413
335
  };
414
336
  } ? N : never;
415
- /** One typed query per object of a source, keyed by the camelCase of its name. */
416
- type ObjectsOf<TObjects extends readonly ObjectBuilderLike$1[]> = { readonly [B in TObjects[number] as CamelCase<NameOf<B>>]: RecordsQuery<B>; };
337
+ /** One typed query per object, keyed by the camelCase of its name. */
338
+ type ObjectsOf<TObjects extends readonly ObjectBuilderLike[]> = { readonly [B in TObjects[number] as CamelCase<NameOf<B>>]: RecordsQuery<B>; };
339
+ /** Any bundle, whatever its name and objects. */
340
+ type AnyBundle = BundleBuilder<string, readonly ObjectBuilderLike[]>;
341
+ /** The object builders of every bundle in a tuple: what the typed client infers from. */
342
+ type ObjectsOfBundles<TBundles extends readonly AnyBundle[]> = TBundles[number]["objectBuilders"];
417
343
  interface Standards {
418
- schema: {
419
- sync(source: SchemaSource, options?: SyncOptions): Promise<SyncResult>;
344
+ bundles: {
345
+ /** Sync a bundle to the workspace; a no-op (`applied: false`) when it already holds this version. */
346
+ sync(bundle: AnyBundle, options?: SyncBundleOptions): Promise<SyncBundleResult>;
420
347
  };
421
348
  /** Untyped access to an object the code does not declare (created at runtime). */
422
349
  from(objectName: string): UntypedRecordsQuery;
@@ -431,9 +358,9 @@ interface Standards {
431
358
  * `STANDARDS_API_URL` / `STANDARDS_API_KEY`, and an explicit value always wins.
432
359
  */
433
360
  type StandardsConfig = Partial<TransportConfig>;
434
- declare function createStandards<const TObjects extends readonly ObjectBuilderLike$1[]>(config: StandardsConfig & {
435
- schema: SchemaSource<TObjects>;
436
- }): Standards & ObjectsOf<TObjects>;
361
+ declare function createStandards<const TBundles extends readonly AnyBundle[]>(config: StandardsConfig & {
362
+ bundles: TBundles;
363
+ }): Standards & ObjectsOf<ObjectsOfBundles<TBundles>>;
437
364
  declare function createStandards(config?: StandardsConfig): Standards;
438
365
  //#endregion
439
- export { UploadFileInput as A, FileInput as B, UpdateManyResult as C, FilesTransport as D, FilesApi as E, AttachToRecordInput as F, SchemaSource as G, IconName as H, AttachToRecordResult as I, defineSchemaSource as J, SchemaSourceConfig as K, DocumentsApi as L, UploadPublicFileInput as M, UploadedFile as N, PrivateUploadedFile as O, createFilesApi as P, DocumentsTransport as R, UpdateManyError as S, CamelCase as T, ObjectBuilderLike$1 as U, UploadTimeoutOption as V, ResolvedSchemaSource as W, resolveSchemaSource as X, hashSchemaSource as Y, sourceIdFromPackageName as Z, RecordsExportOptions as _, SchemaSourceSummary as a, UntypedRecordsQuery as b, syncSchemaSource as c, DeleteManyError as d, DeleteManyResult as f, RecordsAggregateOptions as g, RecordUpdate as h, createStandards as i, UploadPrivateFileInput as j, PublicUploadedFile as k, CreateManyError as l, RecordInput as m, Standards as n, SyncOptions as o, FetchResult as p, ViewInput as q, StandardsConfig as r, SyncResult as s, ObjectsOf as t, CreateManyResult as u, RecordsQuery as v, createRecordsQuery as w, UpdateManyEntry as x, UntypedBuilder as y, createDocumentsApi as z };
366
+ export { UploadPublicFileInput as A, SyncBundleOptions as B, CamelCase as C, PublicUploadedFile as D, PrivateUploadedFile as E, DocumentsApi as F, syncBundle as H, DocumentsTransport as I, createDocumentsApi as L, createFilesApi as M, AttachToRecordInput as N, UploadFileInput as O, AttachToRecordResult as P, FileInput as R, createRecordsQuery as S, FilesTransport as T, SyncTransport as V, UntypedBuilder as _, StandardsConfig as a, UpdateManyError as b, CreateManyResult as c, FetchResult as d, RecordInput as f, RecordsQuery as g, RecordsExportOptions as h, Standards as i, UploadedFile as j, UploadPrivateFileInput as k, DeleteManyError as l, RecordsAggregateOptions as m, ObjectsOf as n, createStandards as o, RecordUpdate as p, ObjectsOfBundles as r, CreateManyError as s, AnyBundle as t, DeleteManyResult as u, UntypedRecordsQuery as v, FilesApi as w, UpdateManyResult as x, UpdateManyEntry as y, UploadTimeoutOption as z };