primitive-admin 1.1.0-alpha.71 → 1.1.0-alpha.73

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 (65) hide show
  1. package/dist/src/commands/apps.js +5 -2
  2. package/dist/src/commands/apps.js.map +1 -1
  3. package/dist/src/commands/database-types.js +13 -313
  4. package/dist/src/commands/database-types.js.map +1 -1
  5. package/dist/src/commands/email-templates.js +3 -3
  6. package/dist/src/commands/email-templates.js.map +1 -1
  7. package/dist/src/commands/env.js +17 -1
  8. package/dist/src/commands/env.js.map +1 -1
  9. package/dist/src/commands/init.d.ts +15 -0
  10. package/dist/src/commands/init.js +158 -22
  11. package/dist/src/commands/init.js.map +1 -1
  12. package/dist/src/commands/integrations.js +30 -14
  13. package/dist/src/commands/integrations.js.map +1 -1
  14. package/dist/src/commands/llm.js +9 -6
  15. package/dist/src/commands/llm.js.map +1 -1
  16. package/dist/src/commands/scripts.d.ts +10 -0
  17. package/dist/src/commands/scripts.js +137 -8
  18. package/dist/src/commands/scripts.js.map +1 -1
  19. package/dist/src/commands/settings.d.ts +18 -0
  20. package/dist/src/commands/settings.js +54 -0
  21. package/dist/src/commands/settings.js.map +1 -0
  22. package/dist/src/commands/sync.d.ts +1 -31
  23. package/dist/src/commands/sync.js +5 -79
  24. package/dist/src/commands/sync.js.map +1 -1
  25. package/dist/src/lib/app-settings-descriptor.js +5 -0
  26. package/dist/src/lib/app-settings-descriptor.js.map +1 -1
  27. package/dist/src/lib/env-resolver-core.d.ts +40 -0
  28. package/dist/src/lib/env-resolver-core.js +60 -0
  29. package/dist/src/lib/env-resolver-core.js.map +1 -1
  30. package/dist/src/lib/generated-config-surfaces.js +19 -0
  31. package/dist/src/lib/generated-config-surfaces.js.map +1 -1
  32. package/dist/src/lib/generated-workflow-model-fields.d.ts +20 -0
  33. package/dist/src/lib/generated-workflow-model-fields.js +53 -0
  34. package/dist/src/lib/generated-workflow-model-fields.js.map +1 -0
  35. package/dist/src/lib/google-client-secret-status.d.ts +35 -0
  36. package/dist/src/lib/google-client-secret-status.js +56 -0
  37. package/dist/src/lib/google-client-secret-status.js.map +1 -0
  38. package/dist/src/lib/init-client-platforms.d.ts +14 -0
  39. package/dist/src/lib/init-client-platforms.js +71 -0
  40. package/dist/src/lib/init-client-platforms.js.map +1 -0
  41. package/dist/src/lib/init-email-redirect-uris.d.ts +37 -0
  42. package/dist/src/lib/init-email-redirect-uris.js +46 -0
  43. package/dist/src/lib/init-email-redirect-uris.js.map +1 -0
  44. package/dist/src/lib/init-ios-links.d.ts +40 -0
  45. package/dist/src/lib/init-ios-links.js +66 -1
  46. package/dist/src/lib/init-ios-links.js.map +1 -1
  47. package/dist/src/lib/integration-selector.d.ts +42 -0
  48. package/dist/src/lib/integration-selector.js +46 -0
  49. package/dist/src/lib/integration-selector.js.map +1 -0
  50. package/dist/src/lib/local-test-cases.d.ts +63 -0
  51. package/dist/src/lib/local-test-cases.js +135 -0
  52. package/dist/src/lib/local-test-cases.js.map +1 -0
  53. package/dist/src/lib/project-config.d.ts +8 -0
  54. package/dist/src/lib/project-config.js +17 -0
  55. package/dist/src/lib/project-config.js.map +1 -1
  56. package/dist/src/lib/test-case-file-names.d.ts +40 -0
  57. package/dist/src/lib/test-case-file-names.js +91 -0
  58. package/dist/src/lib/test-case-file-names.js.map +1 -0
  59. package/dist/src/lib/web-url.d.ts +40 -0
  60. package/dist/src/lib/web-url.js +76 -0
  61. package/dist/src/lib/web-url.js.map +1 -0
  62. package/dist/src/lib/workflow-field-descriptor.d.ts +91 -0
  63. package/dist/src/lib/workflow-field-descriptor.js +153 -0
  64. package/dist/src/lib/workflow-field-descriptor.js.map +1 -0
  65. package/package.json +1 -1
@@ -0,0 +1,20 @@
1
+ /**
2
+ * GENERATED FILE — DO NOT EDIT BY HAND.
3
+ *
4
+ * Source of truth: the `WorkflowDefinition` model in the repo-root
5
+ * `models.yaml` — the one statically-parseable server anchor for the
6
+ * `[workflow]`-level config surface (issue #2326, Phase 1 of #1976).
7
+ *
8
+ * Regenerate with:
9
+ * node cli/scripts/gen-workflow-fields.mjs (runs automatically at CLI prebuild)
10
+ *
11
+ * A CI freshness guard (`cli/scripts/gen-workflow-fields.mjs --check`, also
12
+ * asserted by `cli/tests/unit/workflow-field-descriptor-drift-guard.test.ts`)
13
+ * fails if this committed artifact does not match a fresh parse of
14
+ * `models.yaml`. The same test asserts every field below is classified in
15
+ * `cli/src/lib/workflow-field-descriptor.ts` as synced, structural, or
16
+ * internal — so a new server-side workflow field cannot be silently ignored by
17
+ * the CLI.
18
+ */
19
+ /** Every `WorkflowDefinition` field, in `models.yaml` declaration order (#2326). */
20
+ export declare const GENERATED_WORKFLOW_MODEL_FIELDS: readonly string[];
@@ -0,0 +1,53 @@
1
+ /**
2
+ * GENERATED FILE — DO NOT EDIT BY HAND.
3
+ *
4
+ * Source of truth: the `WorkflowDefinition` model in the repo-root
5
+ * `models.yaml` — the one statically-parseable server anchor for the
6
+ * `[workflow]`-level config surface (issue #2326, Phase 1 of #1976).
7
+ *
8
+ * Regenerate with:
9
+ * node cli/scripts/gen-workflow-fields.mjs (runs automatically at CLI prebuild)
10
+ *
11
+ * A CI freshness guard (`cli/scripts/gen-workflow-fields.mjs --check`, also
12
+ * asserted by `cli/tests/unit/workflow-field-descriptor-drift-guard.test.ts`)
13
+ * fails if this committed artifact does not match a fresh parse of
14
+ * `models.yaml`. The same test asserts every field below is classified in
15
+ * `cli/src/lib/workflow-field-descriptor.ts` as synced, structural, or
16
+ * internal — so a new server-side workflow field cannot be silently ignored by
17
+ * the CLI.
18
+ */
19
+ /** Every `WorkflowDefinition` field, in `models.yaml` declaration order (#2326). */
20
+ export const GENERATED_WORKFLOW_MODEL_FIELDS = [
21
+ "workflowId",
22
+ "appId",
23
+ "workflowKey",
24
+ "name",
25
+ "status",
26
+ "latestRevision",
27
+ "description",
28
+ "stepsR2Key",
29
+ "draftStepsR2Key",
30
+ "draftInputSchema",
31
+ "draftOutputSchema",
32
+ "draftModifiedAt",
33
+ "activeConfigId",
34
+ "inputSchema",
35
+ "outputSchema",
36
+ "perUserMaxRunning",
37
+ "perUserMaxQueued",
38
+ "perAppMaxRunning",
39
+ "perAppMaxQueued",
40
+ "queueTtlSeconds",
41
+ "dequeueOrder",
42
+ "requiresClientApply",
43
+ "syncCallable",
44
+ "accessRule",
45
+ "metadataManifest",
46
+ "runAs",
47
+ "lock",
48
+ "capabilities",
49
+ "createdBy",
50
+ "createdAt",
51
+ "modifiedAt",
52
+ ];
53
+ //# sourceMappingURL=generated-workflow-model-fields.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generated-workflow-model-fields.js","sourceRoot":"","sources":["../../../src/lib/generated-workflow-model-fields.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,oFAAoF;AACpF,MAAM,CAAC,MAAM,+BAA+B,GAAsB;IAChE,YAAY;IACZ,OAAO;IACP,aAAa;IACb,MAAM;IACN,QAAQ;IACR,gBAAgB;IAChB,aAAa;IACb,YAAY;IACZ,iBAAiB;IACjB,kBAAkB;IAClB,mBAAmB;IACnB,iBAAiB;IACjB,gBAAgB;IAChB,aAAa;IACb,cAAc;IACd,mBAAmB;IACnB,kBAAkB;IAClB,kBAAkB;IAClB,iBAAiB;IACjB,iBAAiB;IACjB,cAAc;IACd,qBAAqB;IACrB,cAAc;IACd,YAAY;IACZ,kBAAkB;IAClB,OAAO;IACP,MAAM;IACN,cAAc;IACd,WAAW;IACX,WAAW;IACX,YAAY;CACb,CAAC"}
@@ -0,0 +1,35 @@
1
+ /**
2
+ * The operator-facing warning for an app whose stored `googleClientSecret` is
3
+ * not a `{{secrets.KEY}}` reference (#2256, #2307).
4
+ *
5
+ * The server never sends such a value back: `GET /settings` omits the key and
6
+ * reports `googleClientSecretStatus` in its place, so the only way an operator
7
+ * learns the field is still unmigrated is a command that reads the status and
8
+ * says so. Two do — `apps get` and `config pull` — and
9
+ * each has two statuses to describe, so the wording lives here once and the
10
+ * call sites supply only what genuinely differs: how the field is named in that
11
+ * context, where the value is missing from, and what the un-migrated value
12
+ * blocks.
13
+ *
14
+ * Modelled on `signingSecretStatusWarning` (the same problem for
15
+ * `webhook.signingSecret`), deliberately kept as a separate function: the
16
+ * remediation names a different TOML key, and a `legacy-literal` blocks
17
+ * different things on the two fields.
18
+ *
19
+ * Returns `null` for a status that needs no warning (`reference`, `unset`, or
20
+ * anything a newer server adds), so a call site is one `if` rather than two.
21
+ */
22
+ export declare function googleClientSecretStatusWarning(status: string | null | undefined, context: {
23
+ /** How to name the field, e.g. `"googleClientSecret"`. Starts the sentence. */
24
+ subject: string;
25
+ /** Where the value is missing from, e.g. `"this output"`. */
26
+ withheldFrom: string;
27
+ /**
28
+ * What an un-migrated value blocks, e.g. `"the next settings write will be
29
+ * rejected"`. Every settings write on such an app fails unless it carries a
30
+ * `googleClientSecret` that migrates the field
31
+ * (`validateGoogleClientSecretMigration`), and a pulled `app.toml` never
32
+ * carries one — so for the pull paths this is the concrete consequence.
33
+ */
34
+ blocks: string;
35
+ }): string | null;
@@ -0,0 +1,56 @@
1
+ /**
2
+ * The operator-facing warning for an app whose stored `googleClientSecret` is
3
+ * not a `{{secrets.KEY}}` reference (#2256, #2307).
4
+ *
5
+ * The server never sends such a value back: `GET /settings` omits the key and
6
+ * reports `googleClientSecretStatus` in its place, so the only way an operator
7
+ * learns the field is still unmigrated is a command that reads the status and
8
+ * says so. Two do — `apps get` and `config pull` — and
9
+ * each has two statuses to describe, so the wording lives here once and the
10
+ * call sites supply only what genuinely differs: how the field is named in that
11
+ * context, where the value is missing from, and what the un-migrated value
12
+ * blocks.
13
+ *
14
+ * Modelled on `signingSecretStatusWarning` (the same problem for
15
+ * `webhook.signingSecret`), deliberately kept as a separate function: the
16
+ * remediation names a different TOML key, and a `legacy-literal` blocks
17
+ * different things on the two fields.
18
+ *
19
+ * Returns `null` for a status that needs no warning (`reference`, `unset`, or
20
+ * anything a newer server adds), so a call site is one `if` rather than two.
21
+ */
22
+ export function googleClientSecretStatusWarning(status, context) {
23
+ const remediation = "Store the value with `primitive secrets set KEY --value <value>` and set " +
24
+ 'googleClientSecret = "{{secrets.KEY}}".';
25
+ if (status === "legacy-literal") {
26
+ return (`${context.subject} still holds a raw value rather than a {{secrets.KEY}} reference, ` +
27
+ `so it is withheld from ${context.withheldFrom}. Google sign-in keeps working, but the ` +
28
+ `value is deprecated and ${context.blocks} until it is migrated. ${remediation}`);
29
+ }
30
+ // Not a working legacy literal: the stored value carries reference syntax
31
+ // that resolves to nothing, so Google sign-in is already failing (#2332).
32
+ //
33
+ // Two deliberate differences from the branch above, both to keep the
34
+ // rendered settings output byte-identical to what PR #2293 shipped:
35
+ //
36
+ // - `context.blocks` is unused. A push of the pulled file is rejected for
37
+ // this status too (`validateGoogleClientSecretMigration` gates on
38
+ // `isWithheldSecretStatus`, which covers both), but the sign-in outage is
39
+ // the louder problem and the remediation below already fixes both. The
40
+ // sibling `signingSecretStatusWarning` drops `blocks` in its malformed
41
+ // branch the same way.
42
+ // - The remediation sentence is written out rather than interpolating the
43
+ // `remediation` constant above: this one says "the real client secret",
44
+ // which the shared sentence does not.
45
+ //
46
+ // Both are worth revisiting together if `apps get`'s wording is ever
47
+ // allowed to change.
48
+ if (status === "malformed-reference") {
49
+ return (`${context.subject} is neither a {{secrets.KEY}} reference nor a plain stored value — it ` +
50
+ `carries reference syntax that does not resolve, so it is withheld from ${context.withheldFrom} ` +
51
+ "and Google sign-in is already FAILING. Store the real client secret with " +
52
+ '`primitive secrets set KEY --value <value>` and set googleClientSecret = "{{secrets.KEY}}".');
53
+ }
54
+ return null;
55
+ }
56
+ //# sourceMappingURL=google-client-secret-status.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"google-client-secret-status.js","sourceRoot":"","sources":["../../../src/lib/google-client-secret-status.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,UAAU,+BAA+B,CAC7C,MAAiC,EACjC,OAaC;IAED,MAAM,WAAW,GACf,2EAA2E;QAC3E,yCAAyC,CAAC;IAC5C,IAAI,MAAM,KAAK,gBAAgB,EAAE,CAAC;QAChC,OAAO,CACL,GAAG,OAAO,CAAC,OAAO,oEAAoE;YACtF,0BAA0B,OAAO,CAAC,YAAY,0CAA0C;YACxF,2BAA2B,OAAO,CAAC,MAAM,0BAA0B,WAAW,EAAE,CACjF,CAAC;IACJ,CAAC;IACD,0EAA0E;IAC1E,0EAA0E;IAC1E,EAAE;IACF,qEAAqE;IACrE,oEAAoE;IACpE,EAAE;IACF,4EAA4E;IAC5E,sEAAsE;IACtE,8EAA8E;IAC9E,2EAA2E;IAC3E,2EAA2E;IAC3E,2BAA2B;IAC3B,4EAA4E;IAC5E,4EAA4E;IAC5E,0CAA0C;IAC1C,EAAE;IACF,qEAAqE;IACrE,qBAAqB;IACrB,IAAI,MAAM,KAAK,qBAAqB,EAAE,CAAC;QACrC,OAAO,CACL,GAAG,OAAO,CAAC,OAAO,wEAAwE;YAC1F,0EAA0E,OAAO,CAAC,YAAY,GAAG;YACjG,2EAA2E;YAC3E,6FAA6F,CAC9F,CAAC;IACJ,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC"}
@@ -0,0 +1,14 @@
1
+ import type { Platform } from "./resolve-platform.js";
2
+ /**
3
+ * The platform of the client in `dir`, or null when `dir` is not a client.
4
+ * The ONE definition of the template signals — the AGENTS.md client listing
5
+ * and the both-platforms predicate read it, so they cannot drift.
6
+ */
7
+ export declare function detectClientPlatform(dir: string): Platform | null;
8
+ /**
9
+ * Every platform already present under `projectRoot`, counting a client that
10
+ * IS the root. Deduplicated, in canonical order.
11
+ */
12
+ export declare function discoverClientPlatforms(projectRoot: string): Platform[];
13
+ /** Whether the app ends up with an iOS client AND a web client. */
14
+ export declare function appHasBothPlatforms(planned: Platform[], discovered: Platform[]): boolean;
@@ -0,0 +1,71 @@
1
+ /**
2
+ * Which client platforms an app HAS — the ones this run scaffolds plus the
3
+ * ones already in the repository (#2982).
4
+ *
5
+ * An app with both an iOS and a web client gets the universal-link wiring: the
6
+ * emailed sign-in link becomes the web deployment's https callback, which
7
+ * opens the installed app and still signs in from any browser. So "does this
8
+ * app have both?" decides whether init seeds a `webUrl` and prints the
9
+ * activation checklist.
10
+ *
11
+ * The existing clients are found by the signals the templates ship — a Swift
12
+ * package or Xcode project, a Vite project — so a `functions/` directory with
13
+ * a `package.json` is not mistaken for a client. They are looked for in child
14
+ * directories AND at the project root: `primitive init` still produces the
15
+ * flat single-client layout where the client IS the repository root, and
16
+ * adding the second platform to such a repository is exactly the case this
17
+ * feature exists for (DSO-2982-013).
18
+ */
19
+ import { existsSync, readdirSync } from "fs";
20
+ import { join } from "path";
21
+ /**
22
+ * The platform of the client in `dir`, or null when `dir` is not a client.
23
+ * The ONE definition of the template signals — the AGENTS.md client listing
24
+ * and the both-platforms predicate read it, so they cannot drift.
25
+ */
26
+ export function detectClientPlatform(dir) {
27
+ let hasXcodeProject = false;
28
+ try {
29
+ hasXcodeProject = readdirSync(dir).some((name) => name.endsWith(".xcodeproj"));
30
+ }
31
+ catch {
32
+ return null;
33
+ }
34
+ if (existsSync(join(dir, "Package.swift")) || hasXcodeProject)
35
+ return "ios";
36
+ if (existsSync(join(dir, "package.json")) && existsSync(join(dir, "vite.config.ts"))) {
37
+ return "web";
38
+ }
39
+ return null;
40
+ }
41
+ /**
42
+ * Every platform already present under `projectRoot`, counting a client that
43
+ * IS the root. Deduplicated, in canonical order.
44
+ */
45
+ export function discoverClientPlatforms(projectRoot) {
46
+ const found = new Set();
47
+ const atRoot = detectClientPlatform(projectRoot);
48
+ if (atRoot)
49
+ found.add(atRoot);
50
+ let entries;
51
+ try {
52
+ entries = readdirSync(projectRoot, { withFileTypes: true });
53
+ }
54
+ catch {
55
+ entries = [];
56
+ }
57
+ for (const entry of entries) {
58
+ if (!entry.isDirectory() || entry.name.startsWith("."))
59
+ continue;
60
+ const platform = detectClientPlatform(join(projectRoot, entry.name));
61
+ if (platform)
62
+ found.add(platform);
63
+ }
64
+ return ["web", "ios"].filter((platform) => found.has(platform));
65
+ }
66
+ /** Whether the app ends up with an iOS client AND a web client. */
67
+ export function appHasBothPlatforms(planned, discovered) {
68
+ const platforms = new Set([...planned, ...discovered]);
69
+ return platforms.has("ios") && platforms.has("web");
70
+ }
71
+ //# sourceMappingURL=init-client-platforms.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"init-client-platforms.js","sourceRoot":"","sources":["../../../src/lib/init-client-platforms.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,IAAI,CAAC;AAE7C,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAG5B;;;;GAIG;AACH,MAAM,UAAU,oBAAoB,CAAC,GAAW;IAC9C,IAAI,eAAe,GAAG,KAAK,CAAC;IAC5B,IAAI,CAAC;QACH,eAAe,GAAG,WAAW,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC,CAAC;IACjF,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;IACD,IAAI,UAAU,CAAC,IAAI,CAAC,GAAG,EAAE,eAAe,CAAC,CAAC,IAAI,eAAe;QAAE,OAAO,KAAK,CAAC;IAC5E,IAAI,UAAU,CAAC,IAAI,CAAC,GAAG,EAAE,cAAc,CAAC,CAAC,IAAI,UAAU,CAAC,IAAI,CAAC,GAAG,EAAE,gBAAgB,CAAC,CAAC,EAAE,CAAC;QACrF,OAAO,KAAK,CAAC;IACf,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,uBAAuB,CAAC,WAAmB;IACzD,MAAM,KAAK,GAAG,IAAI,GAAG,EAAY,CAAC;IAElC,MAAM,MAAM,GAAG,oBAAoB,CAAC,WAAW,CAAC,CAAC;IACjD,IAAI,MAAM;QAAE,KAAK,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IAE9B,IAAI,OAAiB,CAAC;IACtB,IAAI,CAAC;QACH,OAAO,GAAG,WAAW,CAAC,WAAW,EAAE,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,CAAC;IAC9D,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,GAAG,EAAE,CAAC;IACf,CAAC;IACD,KAAK,MAAM,KAAK,IAAI,OAAO,EAAE,CAAC;QAC5B,IAAI,CAAC,KAAK,CAAC,WAAW,EAAE,IAAI,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC;YAAE,SAAS;QACjE,MAAM,QAAQ,GAAG,oBAAoB,CAAC,IAAI,CAAC,WAAW,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC;QACrE,IAAI,QAAQ;YAAE,KAAK,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IACpC,CAAC;IAED,OAAQ,CAAC,KAAK,EAAE,KAAK,CAAW,CAAC,MAAM,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC;AAC7E,CAAC;AAED,mEAAmE;AACnE,MAAM,UAAU,mBAAmB,CACjC,OAAmB,EACnB,UAAsB;IAEtB,MAAM,SAAS,GAAG,IAAI,GAAG,CAAW,CAAC,GAAG,OAAO,EAAE,GAAG,UAAU,CAAC,CAAC,CAAC;IACjE,OAAO,SAAS,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,SAAS,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;AACtD,CAAC"}
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Whether init may add a sign-in callback to an app's magic-link allow-list,
3
+ * and what to write (#2982).
4
+ *
5
+ * A combined iOS + web app emails ONE https link — the web app's
6
+ * `/oauth/callback` — and the server matches that target against
7
+ * `emailRedirectUris` fail-closed. So init only points an environment's
8
+ * `webUrl` at a dev origin whose callback the app actually allows; otherwise it
9
+ * would flip a working code-only email into a request that 400s.
10
+ *
11
+ * A brand-new app is seeded with `http://localhost:5173/oauth/callback` at
12
+ * creation, and the dev-port step merges the chosen port's callback — but an
13
+ * app adopted with `--use-existing-app-id` on the default port has been through
14
+ * neither, and its allow-list is whatever it already was.
15
+ *
16
+ * The one thing this must never do is NARROW that list. An app with no
17
+ * `emailRedirectUris` attribute still behaves by the pre-#2891 app-wide
18
+ * `redirectUris`, and writing a fresh single-entry list would silently replace
19
+ * that fallback with our callback — breaking magic-link sign-in for whichever
20
+ * client was relying on it. An explicitly empty list is a deliberate "reject
21
+ * everything" for the same reason. Both are left alone, and init falls back to
22
+ * printing the manual step.
23
+ */
24
+ export type EmailRedirectUriMerge = {
25
+ action: "already-listed";
26
+ } | {
27
+ action: "merge";
28
+ uris: string[];
29
+ } | {
30
+ action: "leave-alone";
31
+ reason: string;
32
+ };
33
+ /**
34
+ * Decide what to do with `existing` (the app's `emailRedirectUris` as the
35
+ * settings API reports it) to make `callbackUri` an allowed target.
36
+ */
37
+ export declare function planEmailRedirectUriMerge(existing: unknown, callbackUri: string): EmailRedirectUriMerge;
@@ -0,0 +1,46 @@
1
+ /**
2
+ * Whether init may add a sign-in callback to an app's magic-link allow-list,
3
+ * and what to write (#2982).
4
+ *
5
+ * A combined iOS + web app emails ONE https link — the web app's
6
+ * `/oauth/callback` — and the server matches that target against
7
+ * `emailRedirectUris` fail-closed. So init only points an environment's
8
+ * `webUrl` at a dev origin whose callback the app actually allows; otherwise it
9
+ * would flip a working code-only email into a request that 400s.
10
+ *
11
+ * A brand-new app is seeded with `http://localhost:5173/oauth/callback` at
12
+ * creation, and the dev-port step merges the chosen port's callback — but an
13
+ * app adopted with `--use-existing-app-id` on the default port has been through
14
+ * neither, and its allow-list is whatever it already was.
15
+ *
16
+ * The one thing this must never do is NARROW that list. An app with no
17
+ * `emailRedirectUris` attribute still behaves by the pre-#2891 app-wide
18
+ * `redirectUris`, and writing a fresh single-entry list would silently replace
19
+ * that fallback with our callback — breaking magic-link sign-in for whichever
20
+ * client was relying on it. An explicitly empty list is a deliberate "reject
21
+ * everything" for the same reason. Both are left alone, and init falls back to
22
+ * printing the manual step.
23
+ */
24
+ /**
25
+ * Decide what to do with `existing` (the app's `emailRedirectUris` as the
26
+ * settings API reports it) to make `callbackUri` an allowed target.
27
+ */
28
+ export function planEmailRedirectUriMerge(existing, callbackUri) {
29
+ if (!Array.isArray(existing)) {
30
+ return {
31
+ action: "leave-alone",
32
+ reason: "this app has no emailRedirectUris list of its own, and writing one would replace the allow-list it behaves by today",
33
+ };
34
+ }
35
+ const uris = existing.filter((value) => typeof value === "string");
36
+ if (uris.length === 0) {
37
+ return {
38
+ action: "leave-alone",
39
+ reason: "this app's emailRedirectUris list is empty, which is a deliberate 'reject every link target'",
40
+ };
41
+ }
42
+ if (uris.includes(callbackUri))
43
+ return { action: "already-listed" };
44
+ return { action: "merge", uris: [...uris, callbackUri] };
45
+ }
46
+ //# sourceMappingURL=init-email-redirect-uris.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"init-email-redirect-uris.js","sourceRoot":"","sources":["../../../src/lib/init-email-redirect-uris.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAOH;;;GAGG;AACH,MAAM,UAAU,yBAAyB,CACvC,QAAiB,EACjB,WAAmB;IAEnB,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC7B,OAAO;YACL,MAAM,EAAE,aAAa;YACrB,MAAM,EACJ,qHAAqH;SACxH,CAAC;IACJ,CAAC;IACD,MAAM,IAAI,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC,KAAK,EAAmB,EAAE,CAAC,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC;IACpF,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACtB,OAAO;YACL,MAAM,EAAE,aAAa;YACrB,MAAM,EACJ,8FAA8F;SACjG,CAAC;IACJ,CAAC;IACD,IAAI,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC;QAAE,OAAO,EAAE,MAAM,EAAE,gBAAgB,EAAE,CAAC;IACpE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,GAAG,IAAI,EAAE,WAAW,CAAC,EAAE,CAAC;AAC3D,CAAC"}
@@ -29,6 +29,20 @@ export interface StampResult {
29
29
  * serializer would drop them.
30
30
  */
31
31
  export declare function stampCallbackScheme(clientDir: string, scheme: string): StampResult;
32
+ /**
33
+ * How to point an environment at the app's web origin — in the shape that
34
+ * actually works (#2982).
35
+ *
36
+ * `primitive env add` CREATES an environment: it requires `--api-url` and
37
+ * refuses a name the config already has. Every environment anyone reads this
38
+ * about already exists (init wrote `dev`; `prod` was added when the app was
39
+ * deployed), so the instruction for those has to be the file, which is also
40
+ * what the docs describe as the way to edit one. The flag is worth naming only
41
+ * where a new environment is being created.
42
+ *
43
+ * `origin` is the placeholder or real origin to show.
44
+ */
45
+ export declare function setWebUrlInstruction(origin: string, indent?: string): string[];
32
46
  /**
33
47
  * What init prints about email sign-in on the iOS path: it already works, and
34
48
  * this is the one opt-in that adds the link.
@@ -46,5 +60,31 @@ export declare function stampCallbackScheme(clientDir: string, scheme: string):
46
60
  export declare function linkOptInGuidance(scheme: string, options?: {
47
61
  registered?: boolean;
48
62
  }): string[];
63
+ /**
64
+ * What init prints for an app with BOTH clients: the emailed sign-in link is
65
+ * already the web app's https callback, and this is what it takes to make that
66
+ * link open the iOS app in production (#2982).
67
+ *
68
+ * Everything here is a post-deploy step by necessity — the production web
69
+ * domain does not exist at init time, and the deploy script never learns the
70
+ * URL it deployed to. The order is load-bearing: the `applinks:` entitlement
71
+ * is the ONLY thing that makes Apple fetch the association document, and
72
+ * Apple's CDN caches what it gets, so it goes last — after the deployed
73
+ * document has been verified.
74
+ *
75
+ * `webOrigin` is the dev origin the run seeded — set only when the run also
76
+ * confirmed that origin's `/oauth/callback` is on the app's allow-list, since
77
+ * that is what makes the seeded link work.
78
+ *
79
+ * `unverifiedDevCallback` is the opposite case: a combined app whose allow-list
80
+ * this run could not vouch for (an adopted app, or no credentials to ask with).
81
+ * Nothing was seeded — the app keeps its working code-only email — and the two
82
+ * steps that turn the link on are printed instead. Neither is set for an
83
+ * adopting run, which does not own the project config at all.
84
+ */
85
+ export declare function universalLinkGuidance(options?: {
86
+ webOrigin?: string;
87
+ unverifiedDevCallback?: string;
88
+ }): string[];
49
89
  /** What init says when the template predates the `PrimitiveAuth` URL type. */
50
90
  export declare function missingUrlTypeGuidance(scheme: string): string[];
@@ -109,6 +109,26 @@ export function stampCallbackScheme(clientDir, scheme) {
109
109
  writeFileSync(plistPath, text.slice(0, dictStart) + rewritten + text.slice(dictEnd));
110
110
  return { outcome: "stamped" };
111
111
  }
112
+ /**
113
+ * How to point an environment at the app's web origin — in the shape that
114
+ * actually works (#2982).
115
+ *
116
+ * `primitive env add` CREATES an environment: it requires `--api-url` and
117
+ * refuses a name the config already has. Every environment anyone reads this
118
+ * about already exists (init wrote `dev`; `prod` was added when the app was
119
+ * deployed), so the instruction for those has to be the file, which is also
120
+ * what the docs describe as the way to edit one. The flag is worth naming only
121
+ * where a new environment is being created.
122
+ *
123
+ * `origin` is the placeholder or real origin to show.
124
+ */
125
+ export function setWebUrlInstruction(origin, indent = " ") {
126
+ return [
127
+ `${indent}add "webUrl": "${origin}" to that environment in .primitive/config.json`,
128
+ `${indent}(\`primitive env add <name> --api-url … --web-url <origin>\` does this only for an`,
129
+ `${indent}environment it CREATES — it cannot edit one that already exists).`,
130
+ ];
131
+ }
112
132
  /**
113
133
  * What init prints about email sign-in on the iOS path: it already works, and
114
134
  * this is the one opt-in that adds the link.
@@ -128,7 +148,11 @@ export function linkOptInGuidance(scheme, options = {}) {
128
148
  const redirectUri = iosMagicLinkRedirectUri(scheme);
129
149
  return [
130
150
  "Email sign-in works now: the email carries a 6-digit code and needs no app settings.",
131
- `To ALSO send a sign-in link that opens this app, add "${redirectUri}" to the existing`,
151
+ "When this app gets a web client, prefer the https link: set the environment's `webUrl` —",
152
+ ...setWebUrlInstruction("https://<your-web-domain>"),
153
+ " The email then carries that origin's /oauth/callback instead — one link that opens this",
154
+ " app where it is installed and signs in through the browser anywhere else.",
155
+ `Until then, to ALSO send a sign-in link that opens this app, add "${redirectUri}" to the existing`,
132
156
  " [auth].emailRedirectUris array in config/app.toml (merge it in — run",
133
157
  " `primitive config pull --only app` first if that file is not there yet), then run",
134
158
  " `primitive config push --only app` and set `authManager.sendsEmailSignInLink = true`.",
@@ -140,6 +164,47 @@ export function linkOptInGuidance(scheme, options = {}) {
140
164
  " authentication.md docs page — 'Make the emailed sign-in link open your app'.",
141
165
  ];
142
166
  }
167
+ /**
168
+ * What init prints for an app with BOTH clients: the emailed sign-in link is
169
+ * already the web app's https callback, and this is what it takes to make that
170
+ * link open the iOS app in production (#2982).
171
+ *
172
+ * Everything here is a post-deploy step by necessity — the production web
173
+ * domain does not exist at init time, and the deploy script never learns the
174
+ * URL it deployed to. The order is load-bearing: the `applinks:` entitlement
175
+ * is the ONLY thing that makes Apple fetch the association document, and
176
+ * Apple's CDN caches what it gets, so it goes last — after the deployed
177
+ * document has been verified.
178
+ *
179
+ * `webOrigin` is the dev origin the run seeded — set only when the run also
180
+ * confirmed that origin's `/oauth/callback` is on the app's allow-list, since
181
+ * that is what makes the seeded link work.
182
+ *
183
+ * `unverifiedDevCallback` is the opposite case: a combined app whose allow-list
184
+ * this run could not vouch for (an adopted app, or no credentials to ask with).
185
+ * Nothing was seeded — the app keeps its working code-only email — and the two
186
+ * steps that turn the link on are printed instead. Neither is set for an
187
+ * adopting run, which does not own the project config at all.
188
+ */
189
+ export function universalLinkGuidance(options = {}) {
190
+ const lines = [
191
+ "This app has both an iOS and a web client, so its sign-in email carries ONE https link:",
192
+ " the web app's /oauth/callback. Tapped where the iOS app is installed it opens the app;",
193
+ " anywhere else it is an ordinary web sign-in. The 6-digit code still works everywhere.",
194
+ ];
195
+ if (options.webOrigin) {
196
+ lines.push(`In dev that link is ${options.webOrigin}/oauth/callback — seeded as the environment's`, " `webUrl`, and allow-listed on the app. Nothing to do.");
197
+ }
198
+ else if (options.unverifiedDevCallback) {
199
+ const origin = options.unverifiedDevCallback.replace(/\/oauth\/callback$/, "");
200
+ lines.push("The link is NOT on yet in dev: this app already existed, and its sign-in link allow-list", ` does not (or could not be checked to) carry ${options.unverifiedDevCallback}. Nothing was`, " changed — the email stays code-only, which works. To turn the link on:", ` 1. Merge "${options.unverifiedDevCallback}" into the existing [auth].emailRedirectUris`, " array in config/app.toml (run `primitive config pull --only app` first if that file is", " not there yet), then `primitive config push --only app`.", ` 2. Then ${setWebUrlInstruction(origin, "")[0]}`, " — the same edit the production steps below describe.");
201
+ }
202
+ else {
203
+ lines.push("Set `webUrl` on this app's environment to turn it on (this run did not write the", " project config):", ...setWebUrlInstruction("https://<your-web-domain>"), " Allow-list that origin's /oauth/callback in [auth].emailRedirectUris too.");
204
+ }
205
+ lines.push("For production, once the web app is deployed:", " 1. Set that environment's `webUrl` to the deployed origin —", ...setWebUrlInstruction("https://<your-web-domain>", " "), " 2. Merge \"https://<your-web-domain>/oauth/callback\" into the existing", " [auth].emailRedirectUris array in config/app.toml (run `primitive config pull --only app`", " first if that file is not there yet), then `primitive config push --only app`.", " 3. In the web client, fill your Apple team and bundle ids into", " public/.well-known/apple-app-site-association.example and rename it (drop .example).", " 4. Deploy, then verify: `curl -i https://<your-web-domain>/.well-known/apple-app-site-association`", " must return 200, application/json and the JSON body — HTML means the SPA fallback answered.", " 5. Only then enable the `applinks:<your-web-domain>` entitlement in the iOS client's", " project.yml (it needs a real DEVELOPMENT_TEAM) and reinstall the app.", " Full checklist: the web client's public/.well-known/README.md, or the authentication", " docs page — 'Make the emailed sign-in link open your app'.");
206
+ return lines;
207
+ }
143
208
  /** What init says when the template predates the `PrimitiveAuth` URL type. */
144
209
  export function missingUrlTypeGuidance(scheme) {
145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AC,qBAAqB,8CAA8C,EAC1F,6FAA6F,EAC7F,+DAA+D,EAC/D,aAAa,oBAAoB,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,EAClD,2DAA2D,CAC5D,CAAC;IACJ,CAAC;SAAM,CAAC;QACN,KAAK,CAAC,IAAI,CACR,kFAAkF,EAClF,oBAAoB,EACpB,GAAG,oBAAoB,CAAC,2BAA2B,CAAC,EACpD,6EAA6E,CAC9E,CAAC;IACJ,CAAC;IACD,KAAK,CAAC,IAAI,CACR,+CAA+C,EAC/C,+DAA+D,EAC/D,GAAG,oBAAoB,CAAC,2BAA2B,EAAE,OAAO,CAAC,EAC7D,2EAA2E,EAC3E,gGAAgG,EAChG,qFAAqF,EACrF,kEAAkE,EAClE,2FAA2F,EAC3F,sGAAsG,EACtG,kGAAkG,EAClG,wFAAwF,EACxF,4EAA4E,EAC5E,wFAAwF,EACxF,8DAA8D,CAC/D,CAAC;IACF,OAAO,KAAK,CAAC;AACf,CAAC;AAED,8EAA8E;AAC9E,MAAM,UAAU,sBAAsB,CAAC,MAAc;IACnD,OAAO;QACL,mDAAmD,4BAA4B,mBAAmB;QAClG,aAAa,MAAM,qEAAqE;QACxF,wCAAwC,4BAA4B,gCAAgC;QACpG,mFAAmF;QACnF,gEAAgE;KACjE,CAAC;AACJ,CAAC"}
@@ -0,0 +1,42 @@
1
+ /**
2
+ * Resolve the identifier the `integrations tests` verbs take (issue #3000).
3
+ *
4
+ * The block-testing endpoints key on the composite `integration#<blockId>` and
5
+ * never check that the block exists, so an identifier that names no
6
+ * integration came back as an empty page rather than a 404: `tests list`
7
+ * printed "No test cases found." and `tests run-all` printed
8
+ * `Total Tests: 0 / Failed: 0` and exited 0. That is success-shaped in CI and
9
+ * indistinguishable from an integration that genuinely has no cases, so a
10
+ * typo, an integration KEY, or an ID from another app all read as "nothing to
11
+ * run".
12
+ *
13
+ * Resolving here — against the app's own integration list — is what makes
14
+ * `Total Tests: 0` mean "this integration exists and has no cases". The list
15
+ * is the one call that can answer both halves: it maps a key to its ID (keys
16
+ * are stored lowercased, so the match is case-insensitive) and it proves the
17
+ * identifier belongs to THIS app. Archived integrations are included, because
18
+ * their cases stay inspectable.
19
+ */
20
+ export interface ResolvedIntegration {
21
+ integrationId: string;
22
+ /** The integration's key, when the summary carries one. */
23
+ integrationKey?: string;
24
+ }
25
+ /** The one method this resolver needs from `ApiClient`. */
26
+ export interface IntegrationLister {
27
+ listIntegrations(appId: string, params?: {
28
+ status?: string;
29
+ cursor?: string;
30
+ limit?: number;
31
+ }): Promise<{
32
+ items: any[];
33
+ nextCursor?: string | null;
34
+ }>;
35
+ }
36
+ /**
37
+ * Map an integration ID or key to its integration ID.
38
+ *
39
+ * Throws — naming the identifier — when nothing in the app matches, so the
40
+ * caller's existing catch prints the message and exits non-zero.
41
+ */
42
+ export declare function resolveIntegrationSelector(client: IntegrationLister, appId: string, selector: string): Promise<ResolvedIntegration>;
@@ -0,0 +1,46 @@
1
+ /**
2
+ * Resolve the identifier the `integrations tests` verbs take (issue #3000).
3
+ *
4
+ * The block-testing endpoints key on the composite `integration#<blockId>` and
5
+ * never check that the block exists, so an identifier that names no
6
+ * integration came back as an empty page rather than a 404: `tests list`
7
+ * printed "No test cases found." and `tests run-all` printed
8
+ * `Total Tests: 0 / Failed: 0` and exited 0. That is success-shaped in CI and
9
+ * indistinguishable from an integration that genuinely has no cases, so a
10
+ * typo, an integration KEY, or an ID from another app all read as "nothing to
11
+ * run".
12
+ *
13
+ * Resolving here — against the app's own integration list — is what makes
14
+ * `Total Tests: 0` mean "this integration exists and has no cases". The list
15
+ * is the one call that can answer both halves: it maps a key to its ID (keys
16
+ * are stored lowercased, so the match is case-insensitive) and it proves the
17
+ * identifier belongs to THIS app. Archived integrations are included, because
18
+ * their cases stay inspectable.
19
+ */
20
+ import { paginateAll } from "./paginate.js";
21
+ /**
22
+ * Map an integration ID or key to its integration ID.
23
+ *
24
+ * Throws — naming the identifier — when nothing in the app matches, so the
25
+ * caller's existing catch prints the message and exits non-zero.
26
+ */
27
+ export async function resolveIntegrationSelector(client, appId, selector) {
28
+ const identifier = (selector ?? "").trim();
29
+ if (!identifier) {
30
+ throw new Error("An integration ID or key is required.");
31
+ }
32
+ const items = await paginateAll((cursor) => client.listIntegrations(appId, cursor ? { cursor } : {}));
33
+ const lowered = identifier.toLowerCase();
34
+ const match = items.find((item) => item?.integrationId === identifier) ??
35
+ items.find((item) => typeof item?.integrationKey === "string" &&
36
+ item.integrationKey.toLowerCase() === lowered);
37
+ if (!match) {
38
+ throw new Error(`No integration '${identifier}' in app ${appId}. ` +
39
+ `Pass an integration key or ID from 'primitive integrations list'.`);
40
+ }
41
+ return {
42
+ integrationId: match.integrationId ?? identifier,
43
+ ...(match.integrationKey ? { integrationKey: match.integrationKey } : {}),
44
+ };
45
+ }
46
+ //# sourceMappingURL=integration-selector.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"integration-selector.js","sourceRoot":"","sources":["../../../src/lib/integration-selector.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAgB5C;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,0BAA0B,CAC9C,MAAyB,EACzB,KAAa,EACb,QAAgB;IAEhB,MAAM,UAAU,GAAG,CAAC,QAAQ,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;IAC3C,IAAI,CAAC,UAAU,EAAE,CAAC;QAChB,MAAM,IAAI,KAAK,CAAC,uCAAuC,CAAC,CAAC;IAC3D,CAAC;IAED,MAAM,KAAK,GAAG,MAAM,WAAW,CAAM,CAAC,MAAM,EAAE,EAAE,CAC9C,MAAM,CAAC,gBAAgB,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CACzD,CAAC;IAEF,MAAM,OAAO,GAAG,UAAU,CAAC,WA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