primitive-admin 1.2.0-alpha.0 → 1.2.0-alpha.2

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 (137) hide show
  1. package/README.md +6 -4
  2. package/dist/bin/primitive.js +22 -24
  3. package/dist/bin/primitive.js.map +1 -1
  4. package/dist/src/commands/agent-sessions.d.ts +20 -0
  5. package/dist/src/commands/agent-sessions.js +275 -0
  6. package/dist/src/commands/agent-sessions.js.map +1 -0
  7. package/dist/src/commands/apps-children.d.ts +54 -0
  8. package/dist/src/commands/apps-children.js +578 -0
  9. package/dist/src/commands/apps-children.js.map +1 -0
  10. package/dist/src/commands/apps.js +88 -9
  11. package/dist/src/commands/apps.js.map +1 -1
  12. package/dist/src/commands/auth-sessions.d.ts +3 -3
  13. package/dist/src/commands/auth-sessions.js +117 -23
  14. package/dist/src/commands/auth-sessions.js.map +1 -1
  15. package/dist/src/commands/auth.js +248 -15
  16. package/dist/src/commands/auth.js.map +1 -1
  17. package/dist/src/commands/connections.js +1 -5
  18. package/dist/src/commands/connections.js.map +1 -1
  19. package/dist/src/commands/databases.js +7 -109
  20. package/dist/src/commands/databases.js.map +1 -1
  21. package/dist/src/commands/documents.d.ts +29 -0
  22. package/dist/src/commands/documents.js +676 -191
  23. package/dist/src/commands/documents.js.map +1 -1
  24. package/dist/src/commands/env.d.ts +9 -1
  25. package/dist/src/commands/env.js +158 -45
  26. package/dist/src/commands/env.js.map +1 -1
  27. package/dist/src/commands/functions.js +7 -1
  28. package/dist/src/commands/functions.js.map +1 -1
  29. package/dist/src/commands/init.js +2 -1
  30. package/dist/src/commands/init.js.map +1 -1
  31. package/dist/src/commands/integrations.js +14 -2
  32. package/dist/src/commands/integrations.js.map +1 -1
  33. package/dist/src/commands/prompts.js +4 -0
  34. package/dist/src/commands/prompts.js.map +1 -1
  35. package/dist/src/commands/scripts.js +1 -1
  36. package/dist/src/commands/scripts.js.map +1 -1
  37. package/dist/src/commands/sessions.js +3 -8
  38. package/dist/src/commands/sessions.js.map +1 -1
  39. package/dist/src/commands/sync-app-settings.d.ts +25 -7
  40. package/dist/src/commands/sync-app-settings.js +81 -20
  41. package/dist/src/commands/sync-app-settings.js.map +1 -1
  42. package/dist/src/commands/sync.d.ts +183 -12
  43. package/dist/src/commands/sync.js +974 -452
  44. package/dist/src/commands/sync.js.map +1 -1
  45. package/dist/src/commands/tokens.js +1 -6
  46. package/dist/src/commands/tokens.js.map +1 -1
  47. package/dist/src/commands/users.js +77 -2
  48. package/dist/src/commands/users.js.map +1 -1
  49. package/dist/src/lib/api-client.d.ts +161 -35
  50. package/dist/src/lib/api-client.js +210 -86
  51. package/dist/src/lib/api-client.js.map +1 -1
  52. package/dist/src/lib/app-settings-descriptor.d.ts +9 -1
  53. package/dist/src/lib/app-settings-descriptor.js +22 -10
  54. package/dist/src/lib/app-settings-descriptor.js.map +1 -1
  55. package/dist/src/lib/auth-flow.d.ts +41 -1
  56. package/dist/src/lib/auth-flow.js +45 -16
  57. package/dist/src/lib/auth-flow.js.map +1 -1
  58. package/dist/src/lib/child-apps-local.d.ts +184 -0
  59. package/dist/src/lib/child-apps-local.js +282 -0
  60. package/dist/src/lib/child-apps-local.js.map +1 -0
  61. package/dist/src/lib/ci-session-request.d.ts +22 -0
  62. package/dist/src/lib/ci-session-request.js +51 -0
  63. package/dist/src/lib/ci-session-request.js.map +1 -0
  64. package/dist/src/lib/codegen-shared/generatedFiles.d.ts +4 -1
  65. package/dist/src/lib/codegen-shared/generatedFiles.js +19 -13
  66. package/dist/src/lib/codegen-shared/generatedFiles.js.map +1 -1
  67. package/dist/src/lib/config-object-descriptor.js +5 -5
  68. package/dist/src/lib/config-object-descriptor.js.map +1 -1
  69. package/dist/src/lib/config-payload.js +2 -3
  70. package/dist/src/lib/config-payload.js.map +1 -1
  71. package/dist/src/lib/config-surface.d.ts +2 -1
  72. package/dist/src/lib/config-surface.js +7 -28
  73. package/dist/src/lib/config-surface.js.map +1 -1
  74. package/dist/src/lib/credentials-store.d.ts +17 -2
  75. package/dist/src/lib/credentials-store.js +72 -6
  76. package/dist/src/lib/credentials-store.js.map +1 -1
  77. package/dist/src/lib/document-export-lookups.d.ts +31 -0
  78. package/dist/src/lib/document-export-lookups.js +53 -0
  79. package/dist/src/lib/document-export-lookups.js.map +1 -0
  80. package/dist/src/lib/document-export-permissions.d.ts +7 -5
  81. package/dist/src/lib/document-export-permissions.js +7 -5
  82. package/dist/src/lib/document-export-permissions.js.map +1 -1
  83. package/dist/src/lib/env-resolver-core.d.ts +69 -1
  84. package/dist/src/lib/env-resolver-core.js +137 -20
  85. package/dist/src/lib/env-resolver-core.js.map +1 -1
  86. package/dist/src/lib/env-resolver.d.ts +14 -2
  87. package/dist/src/lib/env-resolver.js +32 -10
  88. package/dist/src/lib/env-resolver.js.map +1 -1
  89. package/dist/src/lib/function-run.d.ts +4 -1
  90. package/dist/src/lib/function-run.js +24 -4
  91. package/dist/src/lib/function-run.js.map +1 -1
  92. package/dist/src/lib/function-sync.d.ts +5 -2
  93. package/dist/src/lib/function-sync.js +7 -4
  94. package/dist/src/lib/function-sync.js.map +1 -1
  95. package/dist/src/lib/generated-config-surfaces.d.ts +49 -50
  96. package/dist/src/lib/generated-config-surfaces.js +283 -166
  97. package/dist/src/lib/generated-config-surfaces.js.map +1 -1
  98. package/dist/src/lib/generated-sdk-types.d.ts +1 -1
  99. package/dist/src/lib/generated-sdk-types.js +1 -1
  100. package/dist/src/lib/generated-sdk-types.js.map +1 -1
  101. package/dist/src/lib/init-adopt.js +12 -3
  102. package/dist/src/lib/init-adopt.js.map +1 -1
  103. package/dist/src/lib/local-state.d.ts +17 -1
  104. package/dist/src/lib/local-state.js +94 -15
  105. package/dist/src/lib/local-state.js.map +1 -1
  106. package/dist/src/lib/local-test-cases.d.ts +5 -2
  107. package/dist/src/lib/local-test-cases.js +7 -4
  108. package/dist/src/lib/local-test-cases.js.map +1 -1
  109. package/dist/src/lib/log-inspection.d.ts +25 -0
  110. package/dist/src/lib/log-inspection.js +24 -0
  111. package/dist/src/lib/log-inspection.js.map +1 -1
  112. package/dist/src/lib/logout-admin-session.d.ts +2 -1
  113. package/dist/src/lib/logout-admin-session.js +7 -1
  114. package/dist/src/lib/logout-admin-session.js.map +1 -1
  115. package/dist/src/lib/pull-write.d.ts +31 -0
  116. package/dist/src/lib/pull-write.js +49 -0
  117. package/dist/src/lib/pull-write.js.map +1 -0
  118. package/dist/src/lib/root-import-decision.d.ts +59 -0
  119. package/dist/src/lib/root-import-decision.js +95 -0
  120. package/dist/src/lib/root-import-decision.js.map +1 -0
  121. package/dist/src/lib/scope-request.d.ts +69 -0
  122. package/dist/src/lib/scope-request.js +188 -0
  123. package/dist/src/lib/scope-request.js.map +1 -0
  124. package/dist/src/lib/session-id.d.ts +9 -0
  125. package/dist/src/lib/session-id.js +28 -0
  126. package/dist/src/lib/session-id.js.map +1 -0
  127. package/dist/src/lib/snapshots.d.ts +17 -1
  128. package/dist/src/lib/snapshots.js +50 -2
  129. package/dist/src/lib/snapshots.js.map +1 -1
  130. package/dist/src/lib/sync-paths.d.ts +35 -0
  131. package/dist/src/lib/sync-paths.js +57 -5
  132. package/dist/src/lib/sync-paths.js.map +1 -1
  133. package/dist/src/lib/transient-retry.d.ts +34 -0
  134. package/dist/src/lib/transient-retry.js +57 -0
  135. package/dist/src/lib/transient-retry.js.map +1 -0
  136. package/dist/src/types/index.d.ts +21 -4
  137. package/package.json +4 -3
@@ -57,14 +57,49 @@ export declare function syncStatePath(configDir: string): string;
57
57
  * `syncStatePath`) and takes precedence from then on.
58
58
  */
59
59
  export declare function syncStateReadPath(configDir: string): string;
60
+ /**
61
+ * The machine-local directory holding each machine-local environment's
62
+ * baseline (#4117): `<projectRoot>/.primitive/sync-state/<name>.json`.
63
+ */
64
+ export declare const LOCAL_SYNC_STATE_DIR = "sync-state";
60
65
  /**
61
66
  * The directory holding this environment's TOML and its sync-state baseline:
62
67
  * `<projectRoot>/primitive/<env>/`, and nothing else, ever.
63
68
  *
69
+ * For a machine-local environment (#4117) `<env>` is the committed
70
+ * environment named by its `tree`: a child app edits its parent's tree. Its
71
+ * baseline is NOT in that directory — see `resolveSyncStateReadPath`.
72
+ *
64
73
  * Takes no arguments on purpose. An override parameter is the shape a second
65
74
  * resolution path grows back in.
66
75
  */
67
76
  export declare function resolveSyncDir(): string;
77
+ /**
78
+ * A machine-local environment's own baseline. Kept out of the shared tree so
79
+ * a pull, push or init on the child never touches the committed environment's
80
+ * `.sync-state.json` (#4117).
81
+ */
82
+ export declare function localSyncStatePathFor(projectRoot: string, name: string): string;
83
+ /**
84
+ * The directory holding every snapshot backup of the environment `name`, across
85
+ * the apps it has named: `<projectRoot>/.primitive/backups/<name>/`.
86
+ */
87
+ export declare function localBackupsRootFor(projectRoot: string, name: string): string;
88
+ /**
89
+ * Where the current environment's sync-state baseline is READ from.
90
+ *
91
+ * A committed environment: `syncStateReadPath` over its tree, the legacy
92
+ * fallback included. A machine-local environment:
93
+ * `.primitive/sync-state/<name>.json`, with no fallback — a baseline in the
94
+ * shared tree is the committed environment's, never the child's.
95
+ */
96
+ export declare function resolveSyncStateReadPath(): string;
97
+ /**
98
+ * Where the current environment's sync-state baseline is WRITTEN: the tree's
99
+ * `.sync-state.json`, or a machine-local environment's own file (its
100
+ * directory created here, as the tree is by the commands that write it).
101
+ */
102
+ export declare function resolveSyncStateWritePath(): string;
68
103
  /**
69
104
  * The snapshot-backups root for the slot a sync operation belongs to (issue
70
105
  * #578, Phase 1): the machine-local
@@ -25,7 +25,7 @@
25
25
  * environment is an error with a remedy rather than a different directory.
26
26
  */
27
27
  import { existsSync, mkdirSync } from "fs";
28
- import { join } from "path";
28
+ import { dirname, join } from "path";
29
29
  import { requireCurrentEnvironment } from "./env-resolver.js";
30
30
  import { PROJECT_LOCAL_STATE_DIR, PROJECT_TREE_DIR } from "./env-resolver-core.js";
31
31
  /** The sync-state baseline, committed beside the environment's TOML (#3153). */
@@ -65,10 +65,19 @@ export function syncStateReadPath(configDir) {
65
65
  const legacy = join(configDir, LEGACY_SYNC_STATE_FILENAME);
66
66
  return existsSync(legacy) ? legacy : current;
67
67
  }
68
+ /**
69
+ * The machine-local directory holding each machine-local environment's
70
+ * baseline (#4117): `<projectRoot>/.primitive/sync-state/<name>.json`.
71
+ */
72
+ export const LOCAL_SYNC_STATE_DIR = "sync-state";
68
73
  /**
69
74
  * The directory holding this environment's TOML and its sync-state baseline:
70
75
  * `<projectRoot>/primitive/<env>/`, and nothing else, ever.
71
76
  *
77
+ * For a machine-local environment (#4117) `<env>` is the committed
78
+ * environment named by its `tree`: a child app edits its parent's tree. Its
79
+ * baseline is NOT in that directory — see `resolveSyncStateReadPath`.
80
+ *
72
81
  * Takes no arguments on purpose. An override parameter is the shape a second
73
82
  * resolution path grows back in.
74
83
  */
@@ -77,8 +86,52 @@ export function resolveSyncDir() {
77
86
  // Defence-in-depth: the environment name comes from a hand-edited config
78
87
  // file and is the only variable segment left in the tree path, so reject
79
88
  // separators and `..` before joining it into <projectRoot>/primitive/...
80
- assertSafePathComponent(env.name, "environment name");
81
- return join(env.projectRoot, PROJECT_TREE_DIR, env.name);
89
+ assertSafePathComponent(env.tree, "environment name");
90
+ return join(env.projectRoot, PROJECT_TREE_DIR, env.tree);
91
+ }
92
+ /**
93
+ * A machine-local environment's own baseline. Kept out of the shared tree so
94
+ * a pull, push or init on the child never touches the committed environment's
95
+ * `.sync-state.json` (#4117).
96
+ */
97
+ export function localSyncStatePathFor(projectRoot, name) {
98
+ assertSafePathComponent(name, "environment name");
99
+ return join(projectRoot, PROJECT_LOCAL_STATE_DIR, LOCAL_SYNC_STATE_DIR, `${name}.json`);
100
+ }
101
+ /**
102
+ * The directory holding every snapshot backup of the environment `name`, across
103
+ * the apps it has named: `<projectRoot>/.primitive/backups/<name>/`.
104
+ */
105
+ export function localBackupsRootFor(projectRoot, name) {
106
+ assertSafePathComponent(name, "environment name");
107
+ return join(projectRoot, PROJECT_LOCAL_STATE_DIR, "backups", name);
108
+ }
109
+ /**
110
+ * Where the current environment's sync-state baseline is READ from.
111
+ *
112
+ * A committed environment: `syncStateReadPath` over its tree, the legacy
113
+ * fallback included. A machine-local environment:
114
+ * `.primitive/sync-state/<name>.json`, with no fallback — a baseline in the
115
+ * shared tree is the committed environment's, never the child's.
116
+ */
117
+ export function resolveSyncStateReadPath() {
118
+ const env = requireCurrentEnvironment();
119
+ if (env.local)
120
+ return localSyncStatePathFor(env.projectRoot, env.name);
121
+ return syncStateReadPath(resolveSyncDir());
122
+ }
123
+ /**
124
+ * Where the current environment's sync-state baseline is WRITTEN: the tree's
125
+ * `.sync-state.json`, or a machine-local environment's own file (its
126
+ * directory created here, as the tree is by the commands that write it).
127
+ */
128
+ export function resolveSyncStateWritePath() {
129
+ const env = requireCurrentEnvironment();
130
+ if (!env.local)
131
+ return syncStatePath(resolveSyncDir());
132
+ const path = localSyncStatePathFor(env.projectRoot, env.name);
133
+ mkdirSync(dirname(path), { recursive: true });
134
+ return path;
82
135
  }
83
136
  /**
84
137
  * The snapshot-backups root for the slot a sync operation belongs to (issue
@@ -99,9 +152,8 @@ export function resolveSnapshotsRoot(options) {
99
152
  const env = requireCurrentEnvironment();
100
153
  // Same defence-in-depth as resolveSyncDir: never trust appId blindly when
101
154
  // building a file-system path.
102
- assertSafePathComponent(env.name, "environment name");
103
155
  assertSafePathComponent(options.appId, "appId");
104
- return join(env.projectRoot, PROJECT_LOCAL_STATE_DIR, "backups", env.name, options.appId);
156
+ return join(localBackupsRootFor(env.projectRoot, env.name), options.appId);
105
157
  }
106
158
  export function assertSafePathComponent(value, label) {
107
159
  if (typeof value !== "string" ||
@@ -1 +1 @@
1
- {"version":3,"file":"sync-paths.js","sourceRoot":"","sources":["../../../src/lib/sync-paths.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,IAAI,CAAC;AAC3C,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,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AAO,WAAW,EAAE,CAAC;IAEvB,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,WAAW,EAAE,OAAO,EAAE,UAAU,EAAE,CAAC;AACvE,CAAC"}
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Retry a request whose failure says nothing about the request itself.
3
+ *
4
+ * A 5xx, a 429, a 408 or a failure in transport (no status at all) is the
5
+ * server or the network having a bad moment: storage answering "internal
6
+ * error, please try again" is the common one. Every other status is an answer
7
+ * — a refusal, a validation failure, a missing resource — and asking again
8
+ * gets the same answer, so it is thrown at once.
9
+ *
10
+ * This is the CLI's one retry for such failures: the import's writes and the
11
+ * export's lookups both go through it.
12
+ *
13
+ * Only idempotent requests belong here. A retried request may have landed the
14
+ * first time with its response lost, so the second attempt must leave the
15
+ * server where one attempt would have: a read, a blob PUT with the same bytes,
16
+ * a Yjs state merge, an artifact upload to the same key.
17
+ */
18
+ /** The waits between attempts: four attempts in all, about 7.5 s at most. */
19
+ export declare const TRANSIENT_RETRY_DELAYS_MS: number[];
20
+ /** Whether an HTTP status is the server having a bad moment, not an answer. */
21
+ export declare function isTransientStatus(status: number): boolean;
22
+ /** The HTTP status a thrown request carries, or `undefined` when it has none. */
23
+ export declare function failureStatus(error: unknown): number | undefined;
24
+ /** Whether a failed request is worth making again. */
25
+ export declare function isTransientFailure(error: unknown): boolean;
26
+ /**
27
+ * Run `attempt`, retrying a transient failure on the back-off schedule.
28
+ *
29
+ * `onRetry` is told about each failure that is about to be retried, so the
30
+ * caller can say so; the last failure, or the first that is not transient, is
31
+ * thrown unchanged. `sleep` performs each wait; a test can pass one that
32
+ * returns at once.
33
+ */
34
+ export declare function withTransientRetry<T>(attempt: () => Promise<T>, onRetry?: (error: unknown, delayMs: number, attemptNumber: number) => void, delaysMs?: readonly number[], sleep?: (ms: number) => Promise<void>): Promise<T>;
@@ -0,0 +1,57 @@
1
+ /**
2
+ * Retry a request whose failure says nothing about the request itself.
3
+ *
4
+ * A 5xx, a 429, a 408 or a failure in transport (no status at all) is the
5
+ * server or the network having a bad moment: storage answering "internal
6
+ * error, please try again" is the common one. Every other status is an answer
7
+ * — a refusal, a validation failure, a missing resource — and asking again
8
+ * gets the same answer, so it is thrown at once.
9
+ *
10
+ * This is the CLI's one retry for such failures: the import's writes and the
11
+ * export's lookups both go through it.
12
+ *
13
+ * Only idempotent requests belong here. A retried request may have landed the
14
+ * first time with its response lost, so the second attempt must leave the
15
+ * server where one attempt would have: a read, a blob PUT with the same bytes,
16
+ * a Yjs state merge, an artifact upload to the same key.
17
+ */
18
+ /** The waits between attempts: four attempts in all, about 7.5 s at most. */
19
+ export const TRANSIENT_RETRY_DELAYS_MS = [500, 2000, 5000];
20
+ /** Whether an HTTP status is the server having a bad moment, not an answer. */
21
+ export function isTransientStatus(status) {
22
+ return status >= 500 || status === 429 || status === 408;
23
+ }
24
+ /** The HTTP status a thrown request carries, or `undefined` when it has none. */
25
+ export function failureStatus(error) {
26
+ const status = error?.statusCode ?? error?.status;
27
+ return typeof status === "number" ? status : undefined;
28
+ }
29
+ /** Whether a failed request is worth making again. */
30
+ export function isTransientFailure(error) {
31
+ const status = failureStatus(error);
32
+ return status === undefined || isTransientStatus(status);
33
+ }
34
+ const defaultSleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
35
+ /**
36
+ * Run `attempt`, retrying a transient failure on the back-off schedule.
37
+ *
38
+ * `onRetry` is told about each failure that is about to be retried, so the
39
+ * caller can say so; the last failure, or the first that is not transient, is
40
+ * thrown unchanged. `sleep` performs each wait; a test can pass one that
41
+ * returns at once.
42
+ */
43
+ export async function withTransientRetry(attempt, onRetry, delaysMs = TRANSIENT_RETRY_DELAYS_MS, sleep = defaultSleep) {
44
+ for (let failures = 0;; failures++) {
45
+ try {
46
+ return await attempt();
47
+ }
48
+ catch (error) {
49
+ if (failures >= delaysMs.length || !isTransientFailure(error))
50
+ throw error;
51
+ const delayMs = delaysMs[failures];
52
+ onRetry?.(error, delayMs, failures + 1);
53
+ await sleep(delayMs);
54
+ }
55
+ }
56
+ }
57
+ //# sourceMappingURL=transient-retry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transient-retry.js","sourceRoot":"","sources":["../../../src/lib/transient-retry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,6EAA6E;AAC7E,MAAM,CAAC,MAAM,yBAAyB,GAAG,CAAC,GAAG,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;AAE3D,+EAA+E;AAC/E,MAAM,UAAU,iBAAiB,CAAC,MAAc;IAC9C,OAAO,MAAM,IAAI,GAAG,IAAI,MAAM,KAAK,GAAG,IAAI,MAAM,KAAK,GAAG,CAAC;AAC3D,CAAC;AAED,iFAAiF;AACjF,MAAM,UAAU,aAAa,CAAC,KAAc;IAC1C,MAAM,MAAM,GAAI,KAAa,EAAE,UAAU,IAAK,KAAa,EAAE,MAAM,CAAC;IACpE,OAAO,OAAO,MAAM,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC;AACzD,CAAC;AAED,sDAAsD;AACtD,MAAM,UAAU,kBAAkB,CAAC,KAAc;IAC/C,MAAM,MAAM,GAAG,aAAa,CAAC,KAAK,CAAC,CAAC;IACpC,OAAO,MAAM,KAAK,SAAS,IAAI,iBAAiB,CAAC,MAAM,CAAC,CAAC;AAC3D,CAAC;AAED,MAAM,YAAY,GAAG,CAAC,EAAU,EAAE,EAAE,CAClC,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC;AAE1D;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,kBAAkB,CACtC,OAAyB,EACzB,OAA0E,EAC1E,WAA8B,yBAAyB,EACvD,QAAuC,YAAY;IAEnD,KAAK,IAAI,QAAQ,GAAG,CAAC,GAAI,QAAQ,EAAE,EAAE,CAAC;QACpC,IAAI,CAAC;YACH,OAAO,MAAM,OAAO,EAAE,CAAC;QACzB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,QAAQ,IAAI,QAAQ,CAAC,MAAM,IAAI,CAAC,kBAAkB,CAAC,KAAK,CAAC;gBAAE,MAAM,KAAK,CAAC;YAC3E,MAAM,OAAO,GAAG,QAAQ,CAAC,QAAQ,CAAC,CAAC;YACnC,OAAO,EAAE,CAAC,KAAK,EAAE,OAAO,EAAE,QAAQ,GAAG,CAAC,CAAC,CAAC;YACxC,MAAM,KAAK,CAAC,OAAO,CAAC,CAAC;QACvB,CAAC;IACH,CAAC;AACH,CAAC"}
@@ -8,6 +8,27 @@ export interface Credentials {
8
8
  role: "admin" | "super-admin";
9
9
  name?: string;
10
10
  globalAdminAppId?: string;
11
+ /**
12
+ * A 15-minute admin step-up held beside this login (#3889): used on a 403
13
+ * that names `admin`, revoked with it by `primitive logout`.
14
+ */
15
+ stepUp?: StepUpCredentials;
16
+ /**
17
+ * Where these credentials came from: `env` when `PRIMITIVE_TOKEN` supplied
18
+ * them (#3890), absent for a stored login. Credentials from the
19
+ * environment are never written to disk and never cause a stored login to
20
+ * be cleared.
21
+ */
22
+ source?: "env";
23
+ }
24
+ /** An admin step-up session's access token; it has no refresh token. */
25
+ export interface StepUpCredentials {
26
+ accessToken: string;
27
+ expiresAt: string;
28
+ sessionId: string;
29
+ scope: string[];
30
+ /** The apps it is pinned to; empty when unpinned. */
31
+ apps: string[];
11
32
  }
12
33
  export interface AppSummary {
13
34
  appId: string;
@@ -51,10 +72,6 @@ export interface AppSettings {
51
72
  }> | null;
52
73
  hasPasskey?: boolean;
53
74
  emailSignInEnabled?: boolean;
54
- /** @deprecated (#2884) Response-only; always equal to `emailSignInEnabled`. */
55
- magicLinkEnabled?: boolean;
56
- /** @deprecated (#2884) Response-only; always equal to `emailSignInEnabled`. */
57
- otpEnabled?: boolean;
58
75
  appleSignInEnabled?: boolean | null;
59
76
  appleAudiences?: string[] | null;
60
77
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "primitive-admin",
3
- "version": "1.2.0-alpha.0",
3
+ "version": "1.2.0-alpha.2",
4
4
  "description": "CLI for administering Primitive applications",
5
5
  "type": "module",
6
6
  "bin": {
@@ -60,13 +60,14 @@
60
60
  "commander": "^12.1.0",
61
61
  "esbuild": "0.25.12",
62
62
  "inquirer": "^9.2.12",
63
- "js-bao": "0.12.0-alpha.0",
63
+ "js-bao": "0.12.0-alpha.2",
64
64
  "mime-types": "^2.1.35",
65
65
  "open": "^10.0.3",
66
66
  "smol-toml": "1.7.0",
67
67
  "tar": "^7.5.22",
68
68
  "typescript": "^5.7.2",
69
- "ulid": "^2.4.0"
69
+ "ulid": "^2.4.0",
70
+ "yjs": "^13.6.18"
70
71
  },
71
72
  "devDependencies": {
72
73
  "@types/inquirer": "^9.0.9",