@spacefast/common 0.0.13 → 0.0.17

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.
Files changed (154) hide show
  1. package/dist/agents/client-registry.d.ts +22 -0
  2. package/dist/agents/client-registry.js +41 -0
  3. package/dist/agents/connect-targets.d.ts +51 -6
  4. package/dist/agents/connect-targets.js +93 -28
  5. package/dist/brand.d.ts +0 -11
  6. package/dist/brand.js +0 -20
  7. package/dist/config/domains.d.ts +15 -6
  8. package/dist/config/domains.js +24 -10
  9. package/dist/config/postgres-budget.d.ts +3 -0
  10. package/dist/config/postgres-budget.js +6 -1
  11. package/dist/config/postgres-budget.json +2 -1
  12. package/dist/contracts/abuse.js +1 -1
  13. package/dist/contracts/access.d.ts +149 -44
  14. package/dist/contracts/access.js +94 -8
  15. package/dist/contracts/activity.js +5 -1
  16. package/dist/contracts/api-keys.js +9 -9
  17. package/dist/contracts/archives.js +11 -11
  18. package/dist/contracts/beta.js +1 -1
  19. package/dist/contracts/builds.js +14 -14
  20. package/dist/contracts/channels.js +2 -2
  21. package/dist/contracts/comments.d.ts +86 -15
  22. package/dist/contracts/comments.js +116 -20
  23. package/dist/contracts/common.d.ts +12 -12
  24. package/dist/contracts/common.js +33 -30
  25. package/dist/contracts/continuation.js +5 -5
  26. package/dist/contracts/data-source-routes.js +1 -1
  27. package/dist/contracts/device-auth.d.ts +6 -6
  28. package/dist/contracts/device-auth.js +12 -12
  29. package/dist/contracts/docs.d.ts +10 -10
  30. package/dist/contracts/domains.js +39 -33
  31. package/dist/contracts/enums.d.ts +2 -10
  32. package/dist/contracts/enums.js +0 -2
  33. package/dist/contracts/error-code-meta.d.ts +116 -47
  34. package/dist/contracts/error-code-meta.js +37 -16
  35. package/dist/contracts/error-codes.d.ts +7 -4
  36. package/dist/contracts/error-codes.js +46 -21
  37. package/dist/contracts/events.d.ts +10 -3
  38. package/dist/contracts/events.js +33 -5
  39. package/dist/contracts/execution.d.ts +26 -0
  40. package/dist/contracts/execution.js +21 -0
  41. package/dist/contracts/feature-lifecycle.d.ts +21 -24
  42. package/dist/contracts/feature-lifecycle.js +28 -26
  43. package/dist/contracts/features.js +4 -4
  44. package/dist/contracts/functions.d.ts +8 -140
  45. package/dist/contracts/functions.js +9 -19
  46. package/dist/contracts/git.d.ts +1 -1
  47. package/dist/contracts/grants.d.ts +96 -79
  48. package/dist/contracts/grants.js +130 -43
  49. package/dist/contracts/ids.d.ts +2 -2
  50. package/dist/contracts/ids.js +2 -4
  51. package/dist/contracts/internal.js +2 -2
  52. package/dist/contracts/mcp.d.ts +17 -556
  53. package/dist/contracts/mcp.js +9 -103
  54. package/dist/contracts/me.js +3 -4
  55. package/dist/contracts/notifications.d.ts +108 -0
  56. package/dist/contracts/notifications.js +54 -0
  57. package/dist/contracts/oauth-resources.d.ts +18 -1
  58. package/dist/contracts/oauth-resources.js +22 -2
  59. package/dist/contracts/operations.d.ts +2 -50
  60. package/dist/contracts/operations.js +0 -19
  61. package/dist/contracts/pages.d.ts +8 -4
  62. package/dist/contracts/pages.js +16 -3
  63. package/dist/contracts/platform.js +10 -8
  64. package/dist/contracts/problem-document.d.ts +14 -0
  65. package/dist/contracts/problem-document.js +35 -0
  66. package/dist/contracts/push-new.d.ts +21 -6
  67. package/dist/contracts/push-new.js +3 -7
  68. package/dist/contracts/resources.d.ts +8 -7
  69. package/dist/contracts/resources.js +9 -6
  70. package/dist/contracts/runtime-api.d.ts +162 -92
  71. package/dist/contracts/runtime-api.js +99 -27
  72. package/dist/contracts/runtime-app.d.ts +41 -11
  73. package/dist/contracts/runtime-app.js +22 -1
  74. package/dist/contracts/runtime-db.d.ts +424 -0
  75. package/dist/contracts/runtime-db.js +108 -0
  76. package/dist/contracts/runtime-storage.d.ts +120 -0
  77. package/dist/contracts/runtime-storage.js +40 -0
  78. package/dist/contracts/sf-config-v1.d.ts +49 -1
  79. package/dist/contracts/sf-config-v1.js +2 -2
  80. package/dist/contracts/sites.d.ts +1 -0
  81. package/dist/contracts/sites.js +20 -12
  82. package/dist/contracts/space-config.d.ts +62 -22
  83. package/dist/contracts/space-config.js +173 -47
  84. package/dist/contracts/spaces.d.ts +79 -45
  85. package/dist/contracts/spaces.js +66 -50
  86. package/dist/contracts/superadmin-spaces.d.ts +13 -2
  87. package/dist/contracts/superadmin-spaces.js +15 -0
  88. package/dist/contracts/superadmin-tenants.js +4 -4
  89. package/dist/contracts/superadmin.d.ts +4 -0
  90. package/dist/contracts/superadmin.js +14 -1
  91. package/dist/contracts/tags.d.ts +17 -17
  92. package/dist/contracts/tags.js +1 -1
  93. package/dist/contracts/teams.js +25 -16
  94. package/dist/contracts/theme-json.js +1 -1
  95. package/dist/contracts/transfers.js +4 -4
  96. package/dist/contracts/variables.js +3 -3
  97. package/dist/contracts/zero.d.ts +204 -338
  98. package/dist/contracts/zero.js +94 -98
  99. package/dist/dashboard-paths/index.d.ts +16 -1
  100. package/dist/dashboard-paths/index.js +18 -0
  101. package/dist/docs/agent-handoff-document.d.ts +2 -2
  102. package/dist/docs/agent-handoff-document.js +8 -7
  103. package/dist/docs/agent-prose.d.ts +22 -3
  104. package/dist/docs/agent-prose.js +221 -51
  105. package/dist/docs/agent-setup.d.ts +13 -10
  106. package/dist/docs/agent-setup.js +279 -53
  107. package/dist/docs/agent-solutions.d.ts +6 -6
  108. package/dist/docs/agent-solutions.js +23 -21
  109. package/dist/docs/catalog.d.ts +29 -74
  110. package/dist/docs/catalog.js +65 -92
  111. package/dist/docs/error-docs.js +293 -221
  112. package/dist/docs/skill-distribution.d.ts +2 -0
  113. package/dist/docs/skill-distribution.js +7 -4
  114. package/dist/docs/skills.d.ts +546 -0
  115. package/dist/docs/skills.js +340 -0
  116. package/dist/utils/browser-credential.d.ts +19 -0
  117. package/dist/utils/browser-credential.js +62 -0
  118. package/dist/utils/comment-avatars.d.ts +7 -0
  119. package/dist/utils/comment-avatars.js +42 -0
  120. package/dist/utils/content-type.d.ts +3 -3
  121. package/dist/utils/content-type.js +38 -61
  122. package/dist/utils/domain-diagnostics.d.ts +5 -5
  123. package/dist/utils/domain-diagnostics.js +21 -10
  124. package/dist/utils/local-space-state.d.ts +78 -4
  125. package/dist/utils/local-space-state.js +383 -82
  126. package/dist/utils/one-shot-replay.d.ts +14 -0
  127. package/dist/utils/one-shot-replay.js +21 -0
  128. package/dist/utils/page-preview.d.ts +7 -0
  129. package/dist/utils/page-preview.js +9 -0
  130. package/dist/utils/pages.d.ts +2 -11
  131. package/dist/utils/pages.js +58 -14
  132. package/dist/utils/publish-form-data.d.ts +22 -0
  133. package/dist/utils/publish-form-data.js +26 -0
  134. package/dist/utils/publish-policy.js +20 -4
  135. package/dist/utils/query-keys.d.ts +7 -4
  136. package/dist/utils/query-keys.js +13 -4
  137. package/dist/utils/runtime-paths.d.ts +3 -0
  138. package/dist/utils/runtime-paths.js +7 -0
  139. package/dist/utils/secure-local-file.d.ts +73 -0
  140. package/dist/utils/secure-local-file.js +1373 -0
  141. package/dist/utils/space-config.d.ts +13 -4
  142. package/dist/utils/space-config.js +123 -15
  143. package/dist/utils/storage-policy.d.ts +20 -0
  144. package/dist/utils/storage-policy.fixtures.json +174 -0
  145. package/dist/utils/storage-policy.js +193 -0
  146. package/dist/utils/upload-session.d.ts +12 -1
  147. package/dist/utils/upload-session.js +37 -2
  148. package/dist/utils/version-file-browser.d.ts +13 -0
  149. package/dist/utils/version-file-browser.js +59 -0
  150. package/package.json +19 -1
  151. package/dist/contracts/mounts.d.ts +0 -142
  152. package/dist/contracts/mounts.js +0 -56
  153. package/dist/utils/asset-fingerprint.d.ts +0 -64
  154. package/dist/utils/asset-fingerprint.js +0 -620
@@ -3,8 +3,20 @@ import { addressDnsInstructionIsObserved, addressDnsInstructionsForHostname, uns
3
3
  export function domainRequiredActions(hostnameDiagnostics) {
4
4
  const actions = [];
5
5
  for (const entry of hostnameDiagnostics) {
6
- const unsupportedRecords = entry.dns.records
7
- ? unsupportedAddressDnsRecordsForHostname({ ...entry, records: entry.dns.records })
6
+ const records = entry.dns.records
7
+ ? {
8
+ a: entry.dns.records.a ?? [],
9
+ aaaa: entry.dns.records.aaaa ?? [],
10
+ }
11
+ : undefined;
12
+ const dnsInstructions = entry.dnsInstructions ?? [];
13
+ const providerIps = entry.providerIps ?? [];
14
+ const unsupportedRecords = records
15
+ ? unsupportedAddressDnsRecordsForHostname({
16
+ hostname: entry.hostname,
17
+ dnsInstructions,
18
+ records,
19
+ })
8
20
  : [];
9
21
  actions.push(...unsupportedRecords.map((record) => ({
10
22
  code: "dns_unaccepted_address",
@@ -12,13 +24,12 @@ export function domainRequiredActions(hostnameDiagnostics) {
12
24
  message: `Remove the ${record.type} record on ${record.name} with value ${record.value}; it does not match a Spacefast target for this hostname.`,
13
25
  })));
14
26
  if (!entry.dns.pointsToProvider) {
15
- const routingInstructions = addressDnsInstructionsForHostname(entry);
16
- const observedAddressRecords = entry.dns.records;
17
- const missingRoutingInstructions = observedAddressRecords
18
- ? routingInstructions.filter((instruction) => !addressDnsInstructionIsObserved({
19
- instruction,
20
- records: observedAddressRecords,
21
- }))
27
+ const routingInstructions = addressDnsInstructionsForHostname({
28
+ hostname: entry.hostname,
29
+ dnsInstructions,
30
+ });
31
+ const missingRoutingInstructions = records
32
+ ? routingInstructions.filter((instruction) => !addressDnsInstructionIsObserved({ instruction, records }))
22
33
  : routingInstructions;
23
34
  if (missingRoutingInstructions.length > 0) {
24
35
  actions.push(...missingRoutingInstructions.map((instruction) => ({
@@ -28,7 +39,7 @@ export function domainRequiredActions(hostnameDiagnostics) {
28
39
  })));
29
40
  }
30
41
  else if (routingInstructions.length === 0) {
31
- const targets = entry.providerIps.length > 0 ? entry.providerIps.join(", ") : "Spacefast";
42
+ const targets = providerIps.length > 0 ? providerIps.join(", ") : "Spacefast";
32
43
  actions.push({
33
44
  code: "dns_not_pointing",
34
45
  hostname: entry.hostname,
@@ -13,15 +13,18 @@ export declare const LOCAL_SPACE_STATE_FILE_NAME = "state.json";
13
13
  * `.spacefast/state.json` is the local credential/cache axis: it records the
14
14
  * resolved `spaceId`, provider `apiUrl`, anonymous `claimToken` before claim,
15
15
  * durable `accessToken` after continuation, and small publish caches such as
16
- * `lastVersionId`. It is secret, machine-written, gitignored, and merge-written
17
- * so newer tools preserve unknown fields from older/newer tools.
16
+ * `lastVersionId`. It is secret, machine-written, gitignored, and merge-written.
17
+ * The strict versioned schema fails closed instead of letting an older tool
18
+ * reinterpret fields written under a contract it does not understand.
18
19
  */
19
20
  export declare const localSpaceLinkSchema: z.ZodObject<{
20
21
  team: z.ZodOptional<z.ZodString>;
21
22
  space: z.ZodString;
22
23
  apiBaseUrl: z.ZodOptional<z.ZodString>;
23
24
  }, z.core.$loose>;
25
+ export declare const LOCAL_SPACE_STATE_SCHEMA_VERSION = 1;
24
26
  export declare const localSpaceStateSchema: z.ZodObject<{
27
+ schemaVersion: z.ZodLiteral<1>;
25
28
  spaceId: z.ZodOptional<z.ZodString>;
26
29
  apiUrl: z.ZodOptional<z.ZodString>;
27
30
  teamSlug: z.ZodOptional<z.ZodString>;
@@ -30,11 +33,52 @@ export declare const localSpaceStateSchema: z.ZodObject<{
30
33
  expiresAt: z.ZodOptional<z.ZodString>;
31
34
  accessToken: z.ZodOptional<z.ZodString>;
32
35
  lastVersionId: z.ZodOptional<z.ZodString>;
36
+ pendingOperationId: z.ZodOptional<z.ZodString>;
33
37
  lastVersionUrl: z.ZodOptional<z.ZodString>;
34
38
  lastSpaceUrl: z.ZodOptional<z.ZodString>;
35
- }, z.core.$loose>;
39
+ /** Secret per-checkout entropy used only to namespace replay-safe first publishes. */
40
+ anonymousPublishNonce: z.ZodOptional<z.ZodString>;
41
+ /** Unsettled first-publish mutation. Retries must reuse this exact key. */
42
+ pendingPublish: z.ZodOptional<z.ZodObject<{
43
+ key: z.ZodString;
44
+ principal: z.ZodString;
45
+ kind: z.ZodEnum<{
46
+ anonymous: "anonymous";
47
+ authenticated: "authenticated";
48
+ }>;
49
+ intent: z.ZodOptional<z.ZodString>;
50
+ createdAt: z.ZodString;
51
+ }, z.core.$strict>>;
52
+ /** Settled creation receipt identity retained for invocations that began before its commit. */
53
+ creationReplay: z.ZodOptional<z.ZodObject<{
54
+ key: z.ZodString;
55
+ principal: z.ZodString;
56
+ kind: z.ZodEnum<{
57
+ anonymous: "anonymous";
58
+ authenticated: "authenticated";
59
+ }>;
60
+ intent: z.ZodOptional<z.ZodString>;
61
+ createdAt: z.ZodString;
62
+ }, z.core.$strict>>;
63
+ /** Random replay capability reserved before consuming a claim credential. */
64
+ pendingCredentialReplay: z.ZodOptional<z.ZodObject<{
65
+ operation: z.ZodEnum<{
66
+ "claim-rotate": "claim-rotate";
67
+ "claim-exchange": "claim-exchange";
68
+ }>;
69
+ credentialFingerprint: z.ZodString;
70
+ key: z.ZodString;
71
+ principal: z.ZodString;
72
+ createdAt: z.ZodString;
73
+ }, z.core.$strict>>;
74
+ }, z.core.$strict>;
36
75
  export type LocalSpaceLink = z.infer<typeof localSpaceLinkSchema>;
37
76
  export type LocalSpaceStateFile = z.infer<typeof localSpaceStateSchema>;
77
+ export type LocalSpaceStateWrite = Omit<LocalSpaceStateFile, "schemaVersion"> & {
78
+ schemaVersion?: typeof LOCAL_SPACE_STATE_SCHEMA_VERSION;
79
+ };
80
+ export type LocalCredentialReplay = NonNullable<LocalSpaceStateFile["pendingCredentialReplay"]>;
81
+ export type LocalCredentialReplayOperation = LocalCredentialReplay["operation"];
38
82
  export type DiscoveredLocalSpaceState = {
39
83
  root: string;
40
84
  statePath: string | null;
@@ -48,6 +92,7 @@ export type DiscoveredLocalSpaceState = {
48
92
  claimUrl: string | undefined;
49
93
  expiresAt: string | undefined;
50
94
  lastVersionId: string | undefined;
95
+ pendingOperationId: string | undefined;
51
96
  };
52
97
  export type SaveLocalSpaceStateInput = {
53
98
  spaceId: string;
@@ -58,9 +103,26 @@ export type SaveLocalSpaceStateInput = {
58
103
  expiresAt?: string | undefined;
59
104
  accessToken?: string | undefined;
60
105
  lastVersionId?: string | undefined;
106
+ pendingOperationId?: string | undefined;
61
107
  lastVersionUrl?: string | undefined;
62
108
  lastSpaceUrl?: string | undefined;
109
+ /** Required when replacing one shown-once credential with another. */
110
+ expectedCredential?: {
111
+ claimToken?: string | undefined;
112
+ accessToken?: string | undefined;
113
+ };
114
+ /** Replay reservation completed by this shown-once credential replacement. */
115
+ credentialReplay?: LocalCredentialReplay | undefined;
116
+ /** Explicit relinks may replace another Space; ordinary cache writes may not. */
117
+ replaceSpace?: boolean | undefined;
63
118
  };
119
+ export declare class LocalSpaceStateConflictError extends Error {
120
+ name: string;
121
+ }
122
+ export declare class LocalSpaceStateError extends Error {
123
+ readonly path: string;
124
+ constructor(filePath: string, cause?: unknown);
125
+ }
64
126
  export declare function localSpaceStateDir(root: string): string;
65
127
  export declare function localSpaceStatePath(root: string): string;
66
128
  export declare function localSpaceLinkPath(root: string): string;
@@ -83,7 +145,19 @@ export declare function readLocalSpaceStateAt(root: string): Promise<DiscoveredL
83
145
  export declare function findUpward<T>(probe: (dir: string) => Promise<T | null>, startDir?: string, boundary?: string): Promise<T | null>;
84
146
  export declare function discoverLocalSpaceState(startDir?: string, boundary?: string): Promise<DiscoveredLocalSpaceState | null>;
85
147
  export declare function writeLocalSpaceLink(root: string, link: LocalSpaceLink): Promise<string>;
86
- export declare function writeLocalSpaceState(root: string, state: LocalSpaceStateFile): Promise<string>;
148
+ export declare function mutateLocalSpaceState(root: string, mutate: (current: LocalSpaceStateFile) => LocalSpaceStateWrite, options?: {
149
+ beforeCommit?: (() => void | Promise<void>) | undefined;
150
+ afterBackup?: (() => void | Promise<void>) | undefined;
151
+ /** Fault-injection observer used to synchronize concurrency tests. */
152
+ onConflict?: (() => void | Promise<void>) | undefined;
153
+ }): Promise<LocalSpaceStateFile>;
154
+ export declare function writeLocalSpaceState(root: string, state: LocalSpaceStateWrite): Promise<string>;
155
+ /** Reserve random replay custody before a claim token can be consumed. */
156
+ export declare function reserveLocalCredentialReplay(root: string, input: {
157
+ operation: LocalCredentialReplayOperation;
158
+ claimToken: string;
159
+ allowUnstoredClaimToken?: boolean | undefined;
160
+ }): Promise<LocalCredentialReplay>;
87
161
  export declare function saveLocalSpaceState(root: string, input: SaveLocalSpaceStateInput): Promise<{
88
162
  statePath: string;
89
163
  linkPath: string;