primitive-admin 1.1.0-alpha.4 → 1.1.0-alpha.40

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 (216) hide show
  1. package/README.md +325 -31
  2. package/assets/skill/skills/primitive-platform/SKILL.md +281 -0
  3. package/dist/bin/primitive.d.ts +2 -0
  4. package/dist/bin/primitive.js +266 -16
  5. package/dist/bin/primitive.js.map +1 -1
  6. package/dist/src/commands/admins.d.ts +2 -0
  7. package/dist/src/commands/admins.js +123 -18
  8. package/dist/src/commands/admins.js.map +1 -1
  9. package/dist/src/commands/analytics.d.ts +2 -0
  10. package/dist/src/commands/analytics.js +464 -55
  11. package/dist/src/commands/analytics.js.map +1 -1
  12. package/dist/src/commands/apps.d.ts +2 -0
  13. package/dist/src/commands/apps.js +55 -13
  14. package/dist/src/commands/apps.js.map +1 -1
  15. package/dist/src/commands/auth.d.ts +2 -0
  16. package/dist/src/commands/auth.js +177 -7
  17. package/dist/src/commands/auth.js.map +1 -1
  18. package/dist/src/commands/blob-buckets.d.ts +2 -0
  19. package/dist/src/commands/blob-buckets.js +422 -0
  20. package/dist/src/commands/blob-buckets.js.map +1 -0
  21. package/dist/src/commands/catalog.d.ts +2 -0
  22. package/dist/src/commands/catalog.js +34 -35
  23. package/dist/src/commands/catalog.js.map +1 -1
  24. package/dist/src/commands/collection-type-configs.d.ts +2 -0
  25. package/dist/src/commands/collection-type-configs.js +178 -0
  26. package/dist/src/commands/collection-type-configs.js.map +1 -0
  27. package/dist/src/commands/collections.d.ts +2 -0
  28. package/dist/src/commands/collections.js +515 -0
  29. package/dist/src/commands/collections.js.map +1 -0
  30. package/dist/src/commands/comparisons.d.ts +2 -0
  31. package/dist/src/commands/comparisons.js +6 -6
  32. package/dist/src/commands/comparisons.js.map +1 -1
  33. package/dist/src/commands/cron-triggers.d.ts +2 -0
  34. package/dist/src/commands/cron-triggers.js +357 -0
  35. package/dist/src/commands/cron-triggers.js.map +1 -0
  36. package/dist/src/commands/database-types.d.ts +2 -0
  37. package/dist/src/commands/database-types.js +471 -0
  38. package/dist/src/commands/database-types.js.map +1 -0
  39. package/dist/src/commands/databases.d.ts +2 -0
  40. package/dist/src/commands/databases.js +1462 -83
  41. package/dist/src/commands/databases.js.map +1 -1
  42. package/dist/src/commands/documents.d.ts +2 -0
  43. package/dist/src/commands/documents.js +518 -11
  44. package/dist/src/commands/documents.js.map +1 -1
  45. package/dist/src/commands/email-templates.d.ts +2 -0
  46. package/dist/src/commands/email-templates.js +281 -0
  47. package/dist/src/commands/email-templates.js.map +1 -0
  48. package/dist/src/commands/env.d.ts +12 -0
  49. package/dist/src/commands/env.js +260 -0
  50. package/dist/src/commands/env.js.map +1 -0
  51. package/dist/src/commands/group-type-configs.d.ts +2 -0
  52. package/dist/src/commands/group-type-configs.js +181 -0
  53. package/dist/src/commands/group-type-configs.js.map +1 -0
  54. package/dist/src/commands/groups.d.ts +2 -0
  55. package/dist/src/commands/groups.js +45 -43
  56. package/dist/src/commands/groups.js.map +1 -1
  57. package/dist/src/commands/guides.d.ts +159 -0
  58. package/dist/src/commands/guides.js +449 -35
  59. package/dist/src/commands/guides.js.map +1 -1
  60. package/dist/src/commands/init.d.ts +17 -0
  61. package/dist/src/commands/init.js +811 -201
  62. package/dist/src/commands/init.js.map +1 -1
  63. package/dist/src/commands/integrations.d.ts +2 -0
  64. package/dist/src/commands/integrations.js +533 -46
  65. package/dist/src/commands/integrations.js.map +1 -1
  66. package/dist/src/commands/llm.d.ts +2 -0
  67. package/dist/src/commands/llm.js +4 -2
  68. package/dist/src/commands/llm.js.map +1 -1
  69. package/dist/src/commands/prompts.d.ts +2 -0
  70. package/dist/src/commands/prompts.js +50 -52
  71. package/dist/src/commands/prompts.js.map +1 -1
  72. package/dist/src/commands/rule-sets.d.ts +3 -0
  73. package/dist/src/commands/rule-sets.js +388 -0
  74. package/dist/src/commands/rule-sets.js.map +1 -0
  75. package/dist/src/commands/scripts.d.ts +2 -0
  76. package/dist/src/commands/scripts.js +667 -0
  77. package/dist/src/commands/scripts.js.map +1 -0
  78. package/dist/src/commands/secrets.d.ts +2 -0
  79. package/dist/src/commands/secrets.js +108 -0
  80. package/dist/src/commands/secrets.js.map +1 -0
  81. package/dist/src/commands/skill.d.ts +2 -0
  82. package/dist/src/commands/skill.js +29 -0
  83. package/dist/src/commands/skill.js.map +1 -0
  84. package/dist/src/commands/sync.d.ts +174 -0
  85. package/dist/src/commands/sync.js +4392 -235
  86. package/dist/src/commands/sync.js.map +1 -1
  87. package/dist/src/commands/tokens.d.ts +2 -0
  88. package/dist/src/commands/tokens.js +122 -19
  89. package/dist/src/commands/tokens.js.map +1 -1
  90. package/dist/src/commands/users.d.ts +2 -0
  91. package/dist/src/commands/users.js +440 -22
  92. package/dist/src/commands/users.js.map +1 -1
  93. package/dist/src/commands/waitlist.d.ts +2 -0
  94. package/dist/src/commands/waitlist.js +10 -10
  95. package/dist/src/commands/waitlist.js.map +1 -1
  96. package/dist/src/commands/webhooks.d.ts +2 -0
  97. package/dist/src/commands/webhooks.js +391 -0
  98. package/dist/src/commands/webhooks.js.map +1 -0
  99. package/dist/src/commands/workflows.d.ts +49 -0
  100. package/dist/src/commands/workflows.js +1009 -123
  101. package/dist/src/commands/workflows.js.map +1 -1
  102. package/dist/src/lib/api-client.d.ts +1272 -0
  103. package/dist/src/lib/api-client.js +1115 -83
  104. package/dist/src/lib/api-client.js.map +1 -1
  105. package/dist/src/lib/auth-flow.d.ts +8 -0
  106. package/dist/src/lib/block-layout.d.ts +160 -0
  107. package/dist/src/lib/block-layout.js +451 -0
  108. package/dist/src/lib/block-layout.js.map +1 -0
  109. package/dist/src/lib/cli-manifest.d.ts +60 -0
  110. package/dist/src/lib/cli-manifest.js +70 -0
  111. package/dist/src/lib/cli-manifest.js.map +1 -0
  112. package/dist/src/lib/config.d.ts +53 -0
  113. package/dist/src/lib/config.js +92 -53
  114. package/dist/src/lib/config.js.map +1 -1
  115. package/dist/src/lib/confirm-prompt.d.ts +83 -0
  116. package/dist/src/lib/confirm-prompt.js +110 -0
  117. package/dist/src/lib/confirm-prompt.js.map +1 -0
  118. package/dist/src/lib/constants.d.ts +2 -0
  119. package/dist/src/lib/constants.js +3 -0
  120. package/dist/src/lib/constants.js.map +1 -0
  121. package/dist/src/lib/crash-handlers.d.ts +20 -0
  122. package/dist/src/lib/crash-handlers.js +49 -0
  123. package/dist/src/lib/crash-handlers.js.map +1 -0
  124. package/dist/src/lib/credentials-store.d.ts +79 -0
  125. package/dist/src/lib/credentials-store.js +307 -0
  126. package/dist/src/lib/credentials-store.js.map +1 -0
  127. package/dist/src/lib/csv.d.ts +48 -0
  128. package/dist/src/lib/csv.js +177 -0
  129. package/dist/src/lib/csv.js.map +1 -0
  130. package/dist/src/lib/db-codegen/dbFingerprint.d.ts +10 -0
  131. package/dist/src/lib/db-codegen/dbFingerprint.js +17 -0
  132. package/dist/src/lib/db-codegen/dbFingerprint.js.map +1 -0
  133. package/dist/src/lib/db-codegen/dbGenerator.d.ts +111 -0
  134. package/dist/src/lib/db-codegen/dbGenerator.js +371 -0
  135. package/dist/src/lib/db-codegen/dbGenerator.js.map +1 -0
  136. package/dist/src/lib/db-codegen/dbNaming.d.ts +45 -0
  137. package/dist/src/lib/db-codegen/dbNaming.js +104 -0
  138. package/dist/src/lib/db-codegen/dbNaming.js.map +1 -0
  139. package/dist/src/lib/db-codegen/dbTemplates.d.ts +97 -0
  140. package/dist/src/lib/db-codegen/dbTemplates.js +159 -0
  141. package/dist/src/lib/db-codegen/dbTemplates.js.map +1 -0
  142. package/dist/src/lib/db-codegen/dbTsTypes.d.ts +78 -0
  143. package/dist/src/lib/db-codegen/dbTsTypes.js +112 -0
  144. package/dist/src/lib/db-codegen/dbTsTypes.js.map +1 -0
  145. package/dist/src/lib/env-resolver.d.ts +62 -0
  146. package/dist/src/lib/env-resolver.js +121 -0
  147. package/dist/src/lib/env-resolver.js.map +1 -0
  148. package/dist/src/lib/fetch.d.ts +5 -0
  149. package/dist/src/lib/generated-allowlist.d.ts +28 -0
  150. package/dist/src/lib/generated-allowlist.js +213 -0
  151. package/dist/src/lib/generated-allowlist.js.map +1 -0
  152. package/dist/src/lib/init-config.d.ts +59 -0
  153. package/dist/src/lib/init-config.js +113 -0
  154. package/dist/src/lib/init-config.js.map +1 -0
  155. package/dist/src/lib/migration-nag.d.ts +49 -0
  156. package/dist/src/lib/migration-nag.js +163 -0
  157. package/dist/src/lib/migration-nag.js.map +1 -0
  158. package/dist/src/lib/output.d.ts +86 -0
  159. package/dist/src/lib/output.js +150 -8
  160. package/dist/src/lib/output.js.map +1 -1
  161. package/dist/src/lib/paginate.d.ts +33 -0
  162. package/dist/src/lib/paginate.js +42 -0
  163. package/dist/src/lib/paginate.js.map +1 -0
  164. package/dist/src/lib/project-config.d.ts +97 -0
  165. package/dist/src/lib/project-config.js +209 -0
  166. package/dist/src/lib/project-config.js.map +1 -0
  167. package/dist/src/lib/query-operators.d.ts +43 -0
  168. package/dist/src/lib/query-operators.js +80 -0
  169. package/dist/src/lib/query-operators.js.map +1 -0
  170. package/dist/src/lib/refresh-admin-credentials.d.ts +65 -0
  171. package/dist/src/lib/refresh-admin-credentials.js +103 -0
  172. package/dist/src/lib/refresh-admin-credentials.js.map +1 -0
  173. package/dist/src/lib/resolve-platform.d.ts +45 -0
  174. package/dist/src/lib/resolve-platform.js +43 -0
  175. package/dist/src/lib/resolve-platform.js.map +1 -0
  176. package/dist/src/lib/skill-installer.d.ts +23 -0
  177. package/dist/src/lib/skill-installer.js +135 -0
  178. package/dist/src/lib/skill-installer.js.map +1 -0
  179. package/dist/src/lib/snapshots.d.ts +99 -0
  180. package/dist/src/lib/snapshots.js +357 -0
  181. package/dist/src/lib/snapshots.js.map +1 -0
  182. package/dist/src/lib/sync-paths.d.ts +72 -0
  183. package/dist/src/lib/sync-paths.js +130 -0
  184. package/dist/src/lib/sync-paths.js.map +1 -0
  185. package/dist/src/lib/template.d.ts +97 -0
  186. package/dist/src/lib/template.js +336 -62
  187. package/dist/src/lib/template.js.map +1 -1
  188. package/dist/src/lib/token-inject.d.ts +56 -0
  189. package/dist/src/lib/token-inject.js +204 -0
  190. package/dist/src/lib/token-inject.js.map +1 -0
  191. package/dist/src/lib/toml-database-config.d.ts +152 -0
  192. package/dist/src/lib/toml-database-config.js +600 -0
  193. package/dist/src/lib/toml-database-config.js.map +1 -0
  194. package/dist/src/lib/toml-metadata-config.d.ts +108 -0
  195. package/dist/src/lib/toml-metadata-config.js +371 -0
  196. package/dist/src/lib/toml-metadata-config.js.map +1 -0
  197. package/dist/src/lib/toml-params-validator.d.ts +129 -0
  198. package/dist/src/lib/toml-params-validator.js +298 -0
  199. package/dist/src/lib/toml-params-validator.js.map +1 -0
  200. package/dist/src/lib/version-check.d.ts +10 -0
  201. package/dist/src/lib/version-check.js +172 -0
  202. package/dist/src/lib/version-check.js.map +1 -0
  203. package/dist/src/lib/workflow-apply.d.ts +66 -0
  204. package/dist/src/lib/workflow-apply.js +117 -0
  205. package/dist/src/lib/workflow-apply.js.map +1 -0
  206. package/dist/src/lib/workflow-fragments.d.ts +41 -0
  207. package/dist/src/lib/workflow-fragments.js +121 -0
  208. package/dist/src/lib/workflow-fragments.js.map +1 -0
  209. package/dist/src/lib/workflow-toml-validator.d.ts +95 -0
  210. package/dist/src/lib/workflow-toml-validator.js +323 -0
  211. package/dist/src/lib/workflow-toml-validator.js.map +1 -0
  212. package/dist/src/types/index.d.ts +520 -0
  213. package/dist/src/validators.d.ts +64 -0
  214. package/dist/src/validators.js +63 -0
  215. package/dist/src/validators.js.map +1 -0
  216. package/package.json +18 -4
@@ -0,0 +1,28 @@
1
+ /**
2
+ * GENERATED FILE — DO NOT EDIT BY HAND.
3
+ *
4
+ * Source of truth: the server step runners in `src/workflows/steps/*.ts` and
5
+ * the universal `BaseStepDefinition` shape in
6
+ * `src/workflows/runner/types.ts`.
7
+ *
8
+ * Regenerate with:
9
+ * node cli/scripts/gen-allowlist.mjs (runs automatically at CLI prebuild)
10
+ *
11
+ * A CI freshness guard (`cli/scripts/gen-allowlist.mjs --check`, also asserted
12
+ * by `cli/tests/unit/workflow-toml-validator-drift-guard.test.ts`) fails if this
13
+ * committed artifact does not match a fresh scan — see issue #998.
14
+ *
15
+ * Two exports:
16
+ * - `GENERATED_ALLOWLISTED_FIELDS` — the union of universal step fields,
17
+ * per-kind fields each runner READS (not what the type declares), and the
18
+ * `collect` `step` structural pass-through. The validator accepts these as
19
+ * top-level step fields for KNOWN kinds.
20
+ * - `GENERATED_KNOWN_KINDS` — the step kinds the server registers. The
21
+ * validator skips the per-field check for an UNKNOWN kind (an old CLI
22
+ * against a newer server) while still running the kind-agnostic
23
+ * misnested-header footgun detector (#685).
24
+ */
25
+ /** Top-level step fields the validator accepts for a known kind (#998). */
26
+ export declare const GENERATED_ALLOWLISTED_FIELDS: readonly string[];
27
+ /** Step kinds the server registers (`defaultRegistry`). Unknown kinds skip the per-field check (#998). */
28
+ export declare const GENERATED_KNOWN_KINDS: readonly string[];
@@ -0,0 +1,213 @@
1
+ /**
2
+ * GENERATED FILE — DO NOT EDIT BY HAND.
3
+ *
4
+ * Source of truth: the server step runners in `src/workflows/steps/*.ts` and
5
+ * the universal `BaseStepDefinition` shape in
6
+ * `src/workflows/runner/types.ts`.
7
+ *
8
+ * Regenerate with:
9
+ * node cli/scripts/gen-allowlist.mjs (runs automatically at CLI prebuild)
10
+ *
11
+ * A CI freshness guard (`cli/scripts/gen-allowlist.mjs --check`, also asserted
12
+ * by `cli/tests/unit/workflow-toml-validator-drift-guard.test.ts`) fails if this
13
+ * committed artifact does not match a fresh scan — see issue #998.
14
+ *
15
+ * Two exports:
16
+ * - `GENERATED_ALLOWLISTED_FIELDS` — the union of universal step fields,
17
+ * per-kind fields each runner READS (not what the type declares), and the
18
+ * `collect` `step` structural pass-through. The validator accepts these as
19
+ * top-level step fields for KNOWN kinds.
20
+ * - `GENERATED_KNOWN_KINDS` — the step kinds the server registers. The
21
+ * validator skips the per-field check for an UNKNOWN kind (an old CLI
22
+ * against a newer server) while still running the kind-agnostic
23
+ * misnested-header footgun detector (#685).
24
+ */
25
+ /** Top-level step fields the validator accepts for a known kind (#998). */
26
+ export const GENERATED_ALLOWLISTED_FIELDS = [
27
+ "_testInputSchema",
28
+ "_testSteps",
29
+ "action",
30
+ "aliasKey",
31
+ "appId",
32
+ "as",
33
+ "asBase64",
34
+ "attachments",
35
+ "blobId",
36
+ "blockKey",
37
+ "blockType",
38
+ "bodyMode",
39
+ "bucketId",
40
+ "bucketKey",
41
+ "cacheTtlSeconds",
42
+ "cases",
43
+ "collectionId",
44
+ "concurrency",
45
+ "configId",
46
+ "content",
47
+ "contentBase64",
48
+ "contentType",
49
+ "context",
50
+ "continueOnError",
51
+ "create",
52
+ "cursor",
53
+ "cursorField",
54
+ "data",
55
+ "databaseId",
56
+ "default",
57
+ "description",
58
+ "direction",
59
+ "documentAlias",
60
+ "documentId",
61
+ "dryRun",
62
+ "durationMs",
63
+ "email",
64
+ "events",
65
+ "expiresInSeconds",
66
+ "feature",
67
+ "filename",
68
+ "filter",
69
+ "filters",
70
+ "forEach",
71
+ "forward",
72
+ "groupBy",
73
+ "groupId",
74
+ "groupType",
75
+ "htmlBody",
76
+ "id",
77
+ "includeRoot",
78
+ "includeUserDetails",
79
+ "input",
80
+ "integrationKey",
81
+ "itemsField",
82
+ "iterationName",
83
+ "kind",
84
+ "limit",
85
+ "limits",
86
+ "maxItems",
87
+ "maxPages",
88
+ "message",
89
+ "messages",
90
+ "metrics",
91
+ "model",
92
+ "modelName",
93
+ "modelOverride",
94
+ "ms",
95
+ "multipartFields",
96
+ "name",
97
+ "onConflict",
98
+ "onPartialFailure",
99
+ "operationName",
100
+ "options",
101
+ "output",
102
+ "ownerOnly",
103
+ "page",
104
+ "pageSize",
105
+ "params",
106
+ "payload",
107
+ "perUser",
108
+ "permission",
109
+ "plugins",
110
+ "prompt",
111
+ "promptKey",
112
+ "query",
113
+ "queryType",
114
+ "recordId",
115
+ "ref",
116
+ "request",
117
+ "route",
118
+ "runIf",
119
+ "saveAs",
120
+ "schema",
121
+ "scope",
122
+ "selector",
123
+ "skipWhenSkipped",
124
+ "sort",
125
+ "source",
126
+ "step",
127
+ "strict",
128
+ "strictParams",
129
+ "subject",
130
+ "successWhen",
131
+ "systemBypass",
132
+ "tag",
133
+ "tags",
134
+ "temperature",
135
+ "templateType",
136
+ "textBody",
137
+ "thinkingLevel",
138
+ "timeout",
139
+ "title",
140
+ "to",
141
+ "toUserId",
142
+ "tool_choice",
143
+ "tools",
144
+ "top_p",
145
+ "type",
146
+ "user",
147
+ "userId",
148
+ "userUlid",
149
+ "variables",
150
+ "version",
151
+ "windowDays",
152
+ "with",
153
+ "workflowKey",
154
+ ];
155
+ /** Step kinds the server registers (`defaultRegistry`). Unknown kinds skip the per-field check (#998). */
156
+ export const GENERATED_KNOWN_KINDS = [
157
+ "analytics.query",
158
+ "analytics.write",
159
+ "analytics.writeForUser",
160
+ "blob.download",
161
+ "blob.signedUrl",
162
+ "blob.upload",
163
+ "block.call",
164
+ "collect",
165
+ "create",
166
+ "database.aggregate",
167
+ "database.applyToQuery",
168
+ "database.count",
169
+ "database.mutate",
170
+ "database.pipeline",
171
+ "database.query",
172
+ "database.syncIndexes",
173
+ "delay",
174
+ "document.count",
175
+ "document.delete",
176
+ "document.getForUser",
177
+ "document.getOrCreateWithAliasForUser",
178
+ "document.getRootForUser",
179
+ "document.listForCollection",
180
+ "document.listForGroup",
181
+ "document.listForUser",
182
+ "document.patch",
183
+ "document.query",
184
+ "document.queryOne",
185
+ "document.resolveAlias",
186
+ "document.resolveAliasForUser",
187
+ "document.save",
188
+ "email.send",
189
+ "event.wait",
190
+ "gemini.countTokens",
191
+ "gemini.generate",
192
+ "gemini.generateRaw",
193
+ "group.addMember",
194
+ "group.checkMembership",
195
+ "group.listMembers",
196
+ "group.listUserMemberships",
197
+ "group.removeAll",
198
+ "group.removeMember",
199
+ "hash",
200
+ "integration.call",
201
+ "iterate-users",
202
+ "llm.chat",
203
+ "noop",
204
+ "prompt.execute",
205
+ "render",
206
+ "script",
207
+ "switch",
208
+ "transform",
209
+ "user.get",
210
+ "user.resolve",
211
+ "workflow.call",
212
+ ];
213
+ //# sourceMappingURL=generated-allowlist.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generated-allowlist.js","sourceRoot":"","sources":["../../../src/lib/generated-allowlist.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,2EAA2E;AAC3E,MAAM,CAAC,MAAM,4BAA4B,GAAsB;IAC7D,kBAAkB;IAClB,YAAY;IACZ,QAAQ;IACR,UAAU;IACV,OAAO;IACP,IAAI;IACJ,UAAU;IACV,aAAa;IACb,QAAQ;IACR,UAAU;IACV,WAAW;IACX,UAAU;IACV,UAAU;IACV,WAAW;IACX,iBAAiB;IACjB,OAAO;IACP,cAAc;IACd,aAAa;IACb,UAAU;IACV,SAAS;IACT,eAAe;IACf,aAAa;IACb,SAAS;IACT,iBAAiB;IACjB,QAAQ;IACR,QAAQ;IACR,aAAa;IACb,MAAM;IACN,YAAY;IACZ,SAAS;IACT,aAAa;IACb,WAAW;IACX,eAAe;IACf,YAAY;IACZ,QAAQ;IACR,YAAY;IACZ,OAAO;IACP,QAAQ;IACR,kBAAkB;IAClB,SAAS;IACT,UAAU;IACV,QAAQ;IACR,SAAS;IACT,SAAS;IACT,SAAS;IACT,SAAS;IACT,SAAS;IACT,WAAW;IACX,UAAU;IACV,IAAI;IACJ,aAAa;IACb,oBAAoB;IACpB,OAAO;IACP,gBAAgB;IAChB,YAAY;IACZ,eAAe;IACf,MAAM;IACN,OAAO;IACP,QAAQ;IACR,UAAU;IACV,UAAU;IACV,SAAS;IACT,UAAU;IACV,SAAS;IACT,OAAO;IACP,WAAW;IACX,eAAe;IACf,IAAI;IACJ,iBAAiB;IACjB,MAAM;IACN,YAAY;IACZ,kBAAkB;IAClB,eAAe;IACf,SAAS;IACT,QAAQ;IACR,WAAW;IACX,MAAM;IACN,UAA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e;IACf,UAAU;IACV,MAAM;IACN,gBAAgB;IAChB,QAAQ;IACR,QAAQ;IACR,QAAQ;IACR,WAAW;IACX,UAAU;IACV,cAAc;IACd,eAAe;CAChB,CAAC"}
@@ -0,0 +1,59 @@
1
+ export declare const INIT_CONFIG_FILENAME = ".primitive-init.toml";
2
+ export interface InitConfig {
3
+ /** Whether to create a new app or use an existing one */
4
+ action: "create" | "use-existing";
5
+ /** App name (required for action = "create") */
6
+ app_name?: string;
7
+ /** Existing app ID (required for action = "use-existing") */
8
+ app_id?: string;
9
+ /** Project directory name */
10
+ dir?: string;
11
+ /** Access mode for the app */
12
+ access_mode?: "public" | "domain" | "invite-only";
13
+ /** Port for local dev server */
14
+ dev_port?: number;
15
+ /** Whether to skip npm install */
16
+ skip_install?: boolean;
17
+ /** Custom server URL */
18
+ server?: string;
19
+ /** Email addresses to invite (for invite-only mode) */
20
+ invite_emails?: string[];
21
+ /** Allowed email domains (for domain mode) */
22
+ allowed_domains?: string[];
23
+ /** Whether to overwrite a non-empty target directory (default: false) */
24
+ overwrite?: boolean;
25
+ /** Target platform for the scaffolded app */
26
+ platform?: "web" | "ios";
27
+ }
28
+ export interface ValidationResult {
29
+ valid: boolean;
30
+ errors: string[];
31
+ }
32
+ /**
33
+ * Resolves the "use an existing app" app id from the two places it can be
34
+ * specified: the `--use-existing-app-id` CLI flag (highest precedence) or an
35
+ * init-config TOML with `action = "use-existing"` + `app_id`.
36
+ *
37
+ * Before this existed, `init` only read the flag, so a `use-existing` TOML fell
38
+ * through to the create-app branch and interactively prompted for an app name —
39
+ * hanging non-interactive (`--config`) runs. (See js-bao-wss #1217.)
40
+ *
41
+ * Returns `undefined` when neither source selects an existing app (i.e. the run
42
+ * should create a new app).
43
+ */
44
+ export declare function resolveUseExistingAppId(flag: string | undefined, initConfig: InitConfig | null): string | undefined;
45
+ /**
46
+ * Parses a TOML string into an InitConfig object.
47
+ * Throws if the string contains invalid TOML.
48
+ */
49
+ export declare function parseInitConfigToml(content: string): InitConfig;
50
+ /**
51
+ * Loads and parses a .primitive-init.toml file from the given directory.
52
+ * Returns null if the file does not exist.
53
+ * Throws if the file exists but contains invalid TOML.
54
+ */
55
+ export declare function loadInitConfig(dir: string): InitConfig | null;
56
+ /**
57
+ * Validates an InitConfig object. Returns a ValidationResult with any errors.
58
+ */
59
+ export declare function validateInitConfig(config: InitConfig): ValidationResult;
@@ -0,0 +1,113 @@
1
+ import { existsSync, readFileSync } from "fs";
2
+ import { join } from "path";
3
+ import * as TOML from "@iarna/toml";
4
+ export const INIT_CONFIG_FILENAME = ".primitive-init.toml";
5
+ /**
6
+ * Resolves the "use an existing app" app id from the two places it can be
7
+ * specified: the `--use-existing-app-id` CLI flag (highest precedence) or an
8
+ * init-config TOML with `action = "use-existing"` + `app_id`.
9
+ *
10
+ * Before this existed, `init` only read the flag, so a `use-existing` TOML fell
11
+ * through to the create-app branch and interactively prompted for an app name —
12
+ * hanging non-interactive (`--config`) runs. (See js-bao-wss #1217.)
13
+ *
14
+ * Returns `undefined` when neither source selects an existing app (i.e. the run
15
+ * should create a new app).
16
+ */
17
+ export function resolveUseExistingAppId(flag, initConfig) {
18
+ if (flag)
19
+ return flag;
20
+ if (initConfig?.action === "use-existing")
21
+ return initConfig.app_id;
22
+ return undefined;
23
+ }
24
+ /**
25
+ * Parses a TOML string into an InitConfig object.
26
+ * Throws if the string contains invalid TOML.
27
+ */
28
+ export function parseInitConfigToml(content) {
29
+ const parsed = TOML.parse(content);
30
+ // The cast is safe because validateInitConfig() is always called after parsing
31
+ return parsed;
32
+ }
33
+ /**
34
+ * Loads and parses a .primitive-init.toml file from the given directory.
35
+ * Returns null if the file does not exist.
36
+ * Throws if the file exists but contains invalid TOML.
37
+ */
38
+ export function loadInitConfig(dir) {
39
+ const configPath = join(dir, INIT_CONFIG_FILENAME);
40
+ if (!existsSync(configPath)) {
41
+ return null;
42
+ }
43
+ const content = readFileSync(configPath, "utf-8");
44
+ return parseInitConfigToml(content);
45
+ }
46
+ /**
47
+ * Validates an InitConfig object. Returns a ValidationResult with any errors.
48
+ */
49
+ export function validateInitConfig(config) {
50
+ const errors = [];
51
+ // action is required
52
+ if (!config.action) {
53
+ errors.push('Missing required field: "action" (must be "create" or "use-existing")');
54
+ }
55
+ else if (config.action !== "create" && config.action !== "use-existing") {
56
+ errors.push('"action" must be "create" or "use-existing"');
57
+ }
58
+ else {
59
+ // Validate action-specific required fields
60
+ if (config.action === "create" && !config.app_name) {
61
+ errors.push('"app_name" is required when action is "create"');
62
+ }
63
+ if (config.action === "use-existing" && !config.app_id) {
64
+ errors.push('"app_id" is required when action is "use-existing"');
65
+ }
66
+ }
67
+ // Validate access_mode if provided
68
+ if (config.access_mode) {
69
+ const validModes = ["public", "domain", "invite-only"];
70
+ if (!validModes.includes(config.access_mode)) {
71
+ errors.push('"access_mode" must be "public", "domain", or "invite-only"');
72
+ }
73
+ else if (config.access_mode === "domain" && (!config.allowed_domains || config.allowed_domains.length === 0)) {
74
+ errors.push('"allowed_domains" is required when access_mode is "domain"');
75
+ }
76
+ }
77
+ // Validate platform if provided. Only "web" and "ios" are supported
78
+ // (`macos` is intentionally rejected until the macOS template is ready).
79
+ if (config.platform !== undefined) {
80
+ if (config.platform !== "web" && config.platform !== "ios") {
81
+ errors.push('"platform" must be "web" or "ios"');
82
+ }
83
+ }
84
+ // Validate dev_port if provided
85
+ if (config.dev_port !== undefined) {
86
+ if (typeof config.dev_port !== "number" || !Number.isInteger(config.dev_port) || config.dev_port < 1 || config.dev_port > 65535) {
87
+ errors.push('"dev_port" must be an integer between 1 and 65535');
88
+ }
89
+ }
90
+ // Validate invite_emails format if provided
91
+ if (config.invite_emails && Array.isArray(config.invite_emails)) {
92
+ for (const email of config.invite_emails) {
93
+ if (!email.includes("@")) {
94
+ errors.push(`Invalid email in invite_emails: "${email}"`);
95
+ }
96
+ }
97
+ }
98
+ // Warn about fields ignored for use-existing action
99
+ if (config.action === "use-existing") {
100
+ const ignoredFields = [];
101
+ if (config.access_mode)
102
+ ignoredFields.push("access_mode");
103
+ if (config.invite_emails && config.invite_emails.length > 0)
104
+ ignoredFields.push("invite_emails");
105
+ if (config.allowed_domains && config.allowed_domains.length > 0)
106
+ ignoredFields.push("allowed_domains");
107
+ if (ignoredFields.length > 0) {
108
+ errors.push(`The following fields are ignored when action is "use-existing": ${ignoredFields.join(", ")}. Remove them to avoid confusion.`);
109
+ }
110
+ }
111
+ return { valid: errors.length === 0, errors };
112
+ }
113
+ //# sourceMappingURL=init-config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"init-config.js","sourceRoot":"","sources":["../../../src/lib/init-config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,IAAI,CAAC;AAC9C,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,KAAK,IAAI,MAAM,aAAa,CAAC;AAEpC,MAAM,CAAC,MAAM,oBAAoB,GAAG,sBAAsB,CAAC;AAkC3D;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,uBAAuB,CACrC,IAAwB,EACxB,UAA6B;IAE7B,IAAI,IAAI;QAAE,OAAO,IAAI,CAAC;IACtB,IAAI,UAAU,EAAE,MAAM,KAAK,cAAc;QAAE,OAAO,UAAU,CAAC,MAAM,CAAC;IACpE,OAAO,SAAS,CAAC;AACnB,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,mBAAmB,CAAC,OAAe;IACjD,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IACnC,+EAA+E;IAC/E,OAAO,MAA+B,CAAC;AACzC,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,cAAc,CAAC,GAAW;IACxC,MAAM,UAAU,GAAG,IAAI,CAAC,GAAG,EAAE,oBAAoB,CAAC,CAAC;IACnD,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC;QAC5B,OAAO,IAAI,CAAC;IACd,CAAC;IAED,MAAM,OAAO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Aa,CAAC,MAAM,GAAG,CAAC;YAAE,aAAa,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;QACjG,IAAI,MAAM,CAAC,eAAe,IAAI,MAAM,CAAC,eAAe,CAAC,MAAM,GAAG,CAAC;YAAE,aAAa,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC;QACvG,IAAI,aAAa,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC7B,MAAM,CAAC,IAAI,CAAC,mEAAmE,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,mCAAmC,CAAC,CAAC;QAC9I,CAAC;IACH,CAAC;IAED,OAAO,EAAE,KAAK,EAAE,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;AAChD,CAAC"}
@@ -0,0 +1,49 @@
1
+ /**
2
+ * Legacy-mode migration nag.
3
+ *
4
+ * Prints a one-time, opt-out, rate-limited startup warning that points
5
+ * users still on the legacy `~/.primitive/credentials.json` config at the
6
+ * project-scoped `primitive env add` migration path. The warning is purely
7
+ * informational — it never mutates anything other than the small
8
+ * `~/.primitive/migration-nag.json` cache used for the 24h rate-limit.
9
+ *
10
+ * Detection signal (warn iff ALL of):
11
+ * 1. `peekLegacyCredentials()` is non-null (legacy creds file present).
12
+ * 2. `findProjectConfigPath()` is null (no project config in scope).
13
+ * 3. `./config/.primitive-sync.json` exists in CWD (strong signal the
14
+ * user has actually run `primitive sync` here — the population at
15
+ * risk from #548).
16
+ *
17
+ * Suppression (skip if ANY of):
18
+ * - `PRIMITIVE_NO_MIGRATE_NAG=1`
19
+ * - `CI` env var set (non-empty)
20
+ * - `!process.stdout.isTTY`
21
+ * - argv contains `--help` / `-h` / `--version` / `-V` / `--json`
22
+ * - Subcommand is `env *`, `init`, `login`, `logout`, or `token`
23
+ * - `now - lastWarnedAt < 24h`
24
+ *
25
+ * Modeled on `cli/src/lib/version-check.ts`: the whole body is wrapped
26
+ * in try/catch that swallows every error so a corrupt cache file or any
27
+ * other unexpected failure can never break the CLI.
28
+ *
29
+ * TODO(#auto-migration): When we ship an interactive auto-migration flow
30
+ * (separate issue from #552), it should either delete this nag cache or
31
+ * bump `lastWarnedAt` far into the future so freshly-migrated users
32
+ * don't see the nag again. The cache lives at `${PRIMITIVE_CONFIG_DIR ||
33
+ * ~/.primitive}/migration-nag.json`.
34
+ */
35
+ export interface MaybeWarnLegacyMigrationOptions {
36
+ argv: string[];
37
+ /**
38
+ * Override the working directory used for project-shape detection and
39
+ * the upward `.primitive/config.json` search. Defaults to
40
+ * `process.cwd()`. Exists so unit tests (which run in worker threads
41
+ * that disallow `process.chdir()`) can point at a tmpdir.
42
+ */
43
+ cwd?: string;
44
+ }
45
+ /**
46
+ * Print the legacy-mode migration nag if the detection signal matches
47
+ * and no suppression condition applies. Never throws.
48
+ */
49
+ export declare function maybeWarnLegacyMigration(options: MaybeWarnLegacyMigrationOptions): void;
@@ -0,0 +1,163 @@
1
+ /**
2
+ * Legacy-mode migration nag.
3
+ *
4
+ * Prints a one-time, opt-out, rate-limited startup warning that points
5
+ * users still on the legacy `~/.primitive/credentials.json` config at the
6
+ * project-scoped `primitive env add` migration path. The warning is purely
7
+ * informational — it never mutates anything other than the small
8
+ * `~/.primitive/migration-nag.json` cache used for the 24h rate-limit.
9
+ *
10
+ * Detection signal (warn iff ALL of):
11
+ * 1. `peekLegacyCredentials()` is non-null (legacy creds file present).
12
+ * 2. `findProjectConfigPath()` is null (no project config in scope).
13
+ * 3. `./config/.primitive-sync.json` exists in CWD (strong signal the
14
+ * user has actually run `primitive sync` here — the population at
15
+ * risk from #548).
16
+ *
17
+ * Suppression (skip if ANY of):
18
+ * - `PRIMITIVE_NO_MIGRATE_NAG=1`
19
+ * - `CI` env var set (non-empty)
20
+ * - `!process.stdout.isTTY`
21
+ * - argv contains `--help` / `-h` / `--version` / `-V` / `--json`
22
+ * - Subcommand is `env *`, `init`, `login`, `logout`, or `token`
23
+ * - `now - lastWarnedAt < 24h`
24
+ *
25
+ * Modeled on `cli/src/lib/version-check.ts`: the whole body is wrapped
26
+ * in try/catch that swallows every error so a corrupt cache file or any
27
+ * other unexpected failure can never break the CLI.
28
+ *
29
+ * TODO(#auto-migration): When we ship an interactive auto-migration flow
30
+ * (separate issue from #552), it should either delete this nag cache or
31
+ * bump `lastWarnedAt` far into the future so freshly-migrated users
32
+ * don't see the nag again. The cache lives at `${PRIMITIVE_CONFIG_DIR ||
33
+ * ~/.primitive}/migration-nag.json`.
34
+ */
35
+ import { existsSync, mkdirSync, readFileSync, writeFileSync } from "fs";
36
+ import { homedir } from "os";
37
+ import { join } from "path";
38
+ import { warn } from "./output.js";
39
+ import { peekLegacyCredentials } from "./credentials-store.js";
40
+ import { findProjectConfigPath } from "./project-config.js";
41
+ const NAG_INTERVAL_MS = 24 * 60 * 60 * 1000;
42
+ /** Resolved per-call so tests can override PRIMITIVE_CONFIG_DIR at runtime. */
43
+ function getConfigDir() {
44
+ return process.env.PRIMITIVE_CONFIG_DIR || join(homedir(), ".primitive");
45
+ }
46
+ function getNagCacheFile() {
47
+ return join(getConfigDir(), "migration-nag.json");
48
+ }
49
+ function ensureConfigDir() {
50
+ const dir = getConfigDir();
51
+ if (!existsSync(dir)) {
52
+ mkdirSync(dir, { recursive: true, mode: 0o700 });
53
+ }
54
+ }
55
+ function loadNagCache() {
56
+ try {
57
+ const file = getNagCacheFile();
58
+ if (!existsSync(file))
59
+ return null;
60
+ const raw = JSON.parse(readFileSync(file, "utf-8"));
61
+ if (!raw || typeof raw !== "object")
62
+ return null;
63
+ if (typeof raw.lastWarnedAt !== "number")
64
+ return null;
65
+ return { lastWarnedAt: raw.lastWarnedAt };
66
+ }
67
+ catch {
68
+ return null;
69
+ }
70
+ }
71
+ function saveNagCache(cache) {
72
+ try {
73
+ ensureConfigDir();
74
+ writeFileSync(getNagCacheFile(), JSON.stringify(cache, null, 2));
75
+ }
76
+ catch {
77
+ // Swallow — at worst the user gets re-nagged next invocation.
78
+ }
79
+ }
80
+ /**
81
+ * Returns true if `argv` indicates the warning should be skipped:
82
+ * - any of `--help` / `-h` / `--version` / `-V` / `--json` present, OR
83
+ * - the subcommand is on the migration path (`env *`, `init`, `login`,
84
+ * `logout`), OR
85
+ * - the subcommand is `token`. The `token` command is contractually
86
+ * stdout-only (callers pipe its output to `--access-token` or paste it
87
+ * into env vars), so any extra warning lines would corrupt that output.
88
+ *
89
+ * `argv` is expected to be the same shape as `process.argv` (i.e. the
90
+ * subcommand sits at index 2, after `node` and the script path). Defensive
91
+ * about short or unusual argv shapes.
92
+ */
93
+ function shouldSuppressByArgv(argv) {
94
+ for (const a of argv) {
95
+ if (a === "--help" || a === "-h" || a === "--version" || a === "-V" || a === "--json") {
96
+ return true;
97
+ }
98
+ }
99
+ const subcommand = argv[2];
100
+ if (subcommand === "env" ||
101
+ subcommand === "init" ||
102
+ subcommand === "login" ||
103
+ subcommand === "logout" ||
104
+ subcommand === "token") {
105
+ return true;
106
+ }
107
+ return false;
108
+ }
109
+ /**
110
+ * Returns true when `cwd` looks like a project that has actually been
111
+ * used with `primitive sync` — specifically, when
112
+ * `<cwd>/config/.primitive-sync.json` exists. Per F4 of the approved
113
+ * plan, this is the only project-shape signal we use; we deliberately
114
+ * do not fall back to `package.json` or `.git` to avoid nagging users
115
+ * who run the CLI for read-only commands from incidental project
116
+ * directories.
117
+ */
118
+ function isProjectShaped(cwd) {
119
+ try {
120
+ return existsSync(join(cwd, "config", ".primitive-sync.json"));
121
+ }
122
+ catch {
123
+ return false;
124
+ }
125
+ }
126
+ /**
127
+ * Print the legacy-mode migration nag if the detection signal matches
128
+ * and no suppression condition applies. Never throws.
129
+ */
130
+ export function maybeWarnLegacyMigration(options) {
131
+ try {
132
+ // --- Fast suppression checks (no disk I/O) ---------------------------
133
+ if (process.env.PRIMITIVE_NO_MIGRATE_NAG === "1")
134
+ return;
135
+ if (process.env.CI)
136
+ return;
137
+ if (!process.stdout.isTTY)
138
+ return;
139
+ if (shouldSuppressByArgv(options.argv))
140
+ return;
141
+ const cwd = options.cwd ?? process.cwd();
142
+ // --- Detection signal -------------------------------------------------
143
+ if (!isProjectShaped(cwd))
144
+ return;
145
+ if (findProjectConfigPath(cwd) !== null)
146
+ return;
147
+ if (peekLegacyCredentials() === null)
148
+ return;
149
+ // --- Rate-limit -------------------------------------------------------
150
+ const cache = loadNagCache();
151
+ const now = Date.now();
152
+ if (cache && now - cache.lastWarnedAt < NAG_INTERVAL_MS)
153
+ return;
154
+ // --- Print --------------------------------------------------------------
155
+ warn("Legacy CLI config detected at ~/.primitive/credentials.json.");
156
+ warn("Run `primitive env add <name> --api-url <url> --app-id <appId>` to upgrade to project-scoped config (see issue #548 for why). Set PRIMITIVE_NO_MIGRATE_NAG=1 to silence.");
157
+ saveNagCache({ lastWarnedAt: now });
158
+ }
159
+ catch {
160
+ // Never let nag errors affect CLI operation — mirrors version-check.ts.
161
+ }
162
+ }
163
+ //# sourceMappingURL=migration-nag.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"migration-nag.js","sourceRoot":"","sources":["../../../src/lib/migration-nag.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAEH,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,IAAI,CAAC;AACxE,OAAO,EAAE,OAAO,EAAE,MAAM,IAAI,CAAC;AAC7B,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AACnC,OAAO,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAC/D,OAAO,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAE5D,MAAM,eAAe,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;AAM5C,+EAA+E;AAC/E,SAAS,YAAY;IACnB,OAAO,OAAO,CAAC,GAAG,CAAC,oBAAoB,IAAI,IAAI,CAAC,OAAO,EAAE,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