primitive-admin 1.1.0-alpha.74 → 1.1.0-alpha.76

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 (128) hide show
  1. package/dist/bin/primitive.js +110 -21
  2. package/dist/bin/primitive.js.map +1 -1
  3. package/dist/src/commands/collection-type-configs.js +1 -1
  4. package/dist/src/commands/collection-type-configs.js.map +1 -1
  5. package/dist/src/commands/config.js +8 -4
  6. package/dist/src/commands/config.js.map +1 -1
  7. package/dist/src/commands/database-type-configs.js +1 -1
  8. package/dist/src/commands/database-type-configs.js.map +1 -1
  9. package/dist/src/commands/databases.js +25 -31
  10. package/dist/src/commands/databases.js.map +1 -1
  11. package/dist/src/commands/documents.js +9 -24
  12. package/dist/src/commands/documents.js.map +1 -1
  13. package/dist/src/commands/env.d.ts +1 -1
  14. package/dist/src/commands/env.js +14 -11
  15. package/dist/src/commands/env.js.map +1 -1
  16. package/dist/src/commands/functions.js +173 -4
  17. package/dist/src/commands/functions.js.map +1 -1
  18. package/dist/src/commands/groups.js +1 -1
  19. package/dist/src/commands/groups.js.map +1 -1
  20. package/dist/src/commands/init.d.ts +12 -15
  21. package/dist/src/commands/init.js +36 -77
  22. package/dist/src/commands/init.js.map +1 -1
  23. package/dist/src/commands/prompts.js +54 -39
  24. package/dist/src/commands/prompts.js.map +1 -1
  25. package/dist/src/commands/rule-sets.js +1 -1
  26. package/dist/src/commands/rule-sets.js.map +1 -1
  27. package/dist/src/commands/scripts.js +17 -4
  28. package/dist/src/commands/scripts.js.map +1 -1
  29. package/dist/src/commands/sync-app-settings.js +2 -4
  30. package/dist/src/commands/sync-app-settings.js.map +1 -1
  31. package/dist/src/commands/sync.d.ts +41 -2
  32. package/dist/src/commands/sync.js +635 -364
  33. package/dist/src/commands/sync.js.map +1 -1
  34. package/dist/src/commands/workflows.js +62 -31
  35. package/dist/src/commands/workflows.js.map +1 -1
  36. package/dist/src/lib/api-client.d.ts +23 -2
  37. package/dist/src/lib/api-client.js +24 -5
  38. package/dist/src/lib/api-client.js.map +1 -1
  39. package/dist/src/lib/app-match-guard.d.ts +44 -0
  40. package/dist/src/lib/app-match-guard.js +72 -0
  41. package/dist/src/lib/app-match-guard.js.map +1 -0
  42. package/dist/src/lib/block-selector.d.ts +58 -0
  43. package/dist/src/lib/block-selector.js +92 -0
  44. package/dist/src/lib/block-selector.js.map +1 -0
  45. package/dist/src/lib/codegen-shared/resolveCodegenSourceDir.d.ts +11 -8
  46. package/dist/src/lib/codegen-shared/resolveCodegenSourceDir.js +108 -54
  47. package/dist/src/lib/codegen-shared/resolveCodegenSourceDir.js.map +1 -1
  48. package/dist/src/lib/config-object-descriptor.js +1 -3
  49. package/dist/src/lib/config-object-descriptor.js.map +1 -1
  50. package/dist/src/lib/config.d.ts +2 -2
  51. package/dist/src/lib/config.js +2 -2
  52. package/dist/src/lib/credentials-store.d.ts +3 -3
  53. package/dist/src/lib/credentials-store.js +3 -3
  54. package/dist/src/lib/credentials-store.js.map +1 -1
  55. package/dist/src/lib/document-export-permissions.d.ts +30 -0
  56. package/dist/src/lib/document-export-permissions.js +54 -0
  57. package/dist/src/lib/document-export-permissions.js.map +1 -0
  58. package/dist/src/lib/env-resolver-core.d.ts +41 -9
  59. package/dist/src/lib/env-resolver-core.js +84 -13
  60. package/dist/src/lib/env-resolver-core.js.map +1 -1
  61. package/dist/src/lib/env-resolver.d.ts +3 -3
  62. package/dist/src/lib/env-resolver.js +2 -2
  63. package/dist/src/lib/function-bundle.d.ts +11 -1
  64. package/dist/src/lib/function-bundle.js +13 -1
  65. package/dist/src/lib/function-bundle.js.map +1 -1
  66. package/dist/src/lib/function-collect.d.ts +123 -0
  67. package/dist/src/lib/function-collect.js +463 -0
  68. package/dist/src/lib/function-collect.js.map +1 -0
  69. package/dist/src/lib/function-db-types.d.ts +149 -0
  70. package/dist/src/lib/function-db-types.js +587 -0
  71. package/dist/src/lib/function-db-types.js.map +1 -0
  72. package/dist/src/lib/function-grants-preflight.d.ts +64 -0
  73. package/dist/src/lib/function-grants-preflight.js +100 -0
  74. package/dist/src/lib/function-grants-preflight.js.map +1 -0
  75. package/dist/src/lib/function-sync.d.ts +23 -0
  76. package/dist/src/lib/function-sync.js +65 -1
  77. package/dist/src/lib/function-sync.js.map +1 -1
  78. package/dist/src/lib/function-triggers.d.ts +6 -0
  79. package/dist/src/lib/function-triggers.js +63 -4
  80. package/dist/src/lib/function-triggers.js.map +1 -1
  81. package/dist/src/lib/generated-config-surfaces.d.ts +340 -0
  82. package/dist/src/lib/generated-config-surfaces.js +669 -17
  83. package/dist/src/lib/generated-config-surfaces.js.map +1 -1
  84. package/dist/src/lib/generated-sdk-types.d.ts +12 -0
  85. package/dist/src/lib/generated-sdk-types.js +13 -0
  86. package/dist/src/lib/generated-sdk-types.js.map +1 -0
  87. package/dist/src/lib/init-adopt.js +2 -2
  88. package/dist/src/lib/init-adopt.js.map +1 -1
  89. package/dist/src/lib/init-assets.js +3 -3
  90. package/dist/src/lib/init-config.d.ts +1 -1
  91. package/dist/src/lib/init-ios-links.js +1 -1
  92. package/dist/src/lib/init-ios-links.js.map +1 -1
  93. package/dist/src/lib/init-plan.d.ts +1 -1
  94. package/dist/src/lib/init-plan.js +1 -1
  95. package/dist/src/lib/init-xcode.d.ts +2 -2
  96. package/dist/src/lib/init-xcode.js +6 -5
  97. package/dist/src/lib/init-xcode.js.map +1 -1
  98. package/dist/src/lib/local-state.d.ts +1 -1
  99. package/dist/src/lib/local-state.js +1 -1
  100. package/dist/src/lib/local-test-cases.d.ts +1 -1
  101. package/dist/src/lib/local-test-cases.js +2 -1
  102. package/dist/src/lib/local-test-cases.js.map +1 -1
  103. package/dist/src/lib/migration-nag.d.ts +2 -2
  104. package/dist/src/lib/migration-nag.js +4 -3
  105. package/dist/src/lib/migration-nag.js.map +1 -1
  106. package/dist/src/lib/project-config.d.ts +23 -20
  107. package/dist/src/lib/project-config.js +27 -45
  108. package/dist/src/lib/project-config.js.map +1 -1
  109. package/dist/src/lib/snapshots.d.ts +2 -2
  110. package/dist/src/lib/snapshots.js +2 -2
  111. package/dist/src/lib/swift-codegen/generator.d.ts +1 -1
  112. package/dist/src/lib/swift-codegen/generator.js +1 -1
  113. package/dist/src/lib/sync-dir-selector.d.ts +1 -1
  114. package/dist/src/lib/sync-dir-selector.js +1 -1
  115. package/dist/src/lib/sync-paths.d.ts +52 -16
  116. package/dist/src/lib/sync-paths.js +68 -22
  117. package/dist/src/lib/sync-paths.js.map +1 -1
  118. package/dist/src/lib/sync-resource-types.d.ts +2 -2
  119. package/dist/src/lib/sync-resource-types.js +2 -2
  120. package/dist/src/lib/template.d.ts +2 -2
  121. package/dist/src/lib/template.js +2 -2
  122. package/dist/src/lib/test-case-keys.d.ts +1 -1
  123. package/dist/src/lib/test-case-keys.js +1 -1
  124. package/dist/src/lib/toml-database-config.js +19 -2
  125. package/dist/src/lib/toml-database-config.js.map +1 -1
  126. package/dist/src/lib/workflow-codegen/generator.d.ts +1 -1
  127. package/dist/src/lib/workflow-codegen/generator.js +1 -1
  128. package/package.json +3 -3
@@ -0,0 +1,149 @@
1
+ /**
2
+ * The typed database handle's generated declarations — #3182 phase 4.
3
+ *
4
+ * The intent settles what the handle is before unified-schemas: "generated at
5
+ * push time from the database type's TOML schema (js-bao's
6
+ * `loadSchemaFromTomlString`; not the client's runtime Yjs discovery): model
7
+ * names and field types in phase 2". So this is a THIRD renderer over the same
8
+ * `describeDbType` IR the TypeScript and Swift client generators already share
9
+ * — not a second parser and not a second idea of what a model is. Inline
10
+ * filter typing waits for unified-schemas, as the intent says.
11
+ *
12
+ * ── Why three files, in `functions/` ─────────────────────────────────────
13
+ *
14
+ * A generated declaration nothing loads is decoration (D3182-006). Function
15
+ * sources live under an environment- and app-specific config-tree path, the
16
+ * CLI's esbuild step never typechecks, and a project's own `tsconfig.json`
17
+ * commonly includes only `src`. So `config push` writes, beside the sources it
18
+ * serves:
19
+ *
20
+ * - `primitive-db-types.d.ts` — the app's database types, and the module
21
+ * augmentation that binds them to `ctx.db`;
22
+ * - `primitive-functions.d.ts` — the SDK's own types. The package is not on
23
+ * npm yet, and even when it is, a config tree is not an npm project:
24
+ * without this the bare `primitive-functions` specifier every function
25
+ * imports would not resolve at all, and the augmentation would have
26
+ * nothing to augment;
27
+ * - `tsconfig.json` — the wiring, so an editor and a bare `tsc` both see all
28
+ * three with nothing for an author to configure.
29
+ *
30
+ * The two `.d.ts` files are GENERATED and rewritten on every push. The tsconfig
31
+ * is SCAFFOLDED once and then left to its author, because it is the file an
32
+ * author has a legitimate reason to adjust — with one exception: the two facts
33
+ * that make the wiring work at all (the `primitive-functions` path mapping and
34
+ * the declarations being in the program) are repaired when they are missing,
35
+ * so a tsconfig written by hand, or scaffolded before the #3209 rename, does
36
+ * not leave push reporting success over a program no compiler can load
37
+ * (SO3182-004). Everything else in the file is left exactly as written.
38
+ *
39
+ * None of the three is part of the pushed envelope: they are regenerated, not
40
+ * round-tripped, and the bundler never sees them (types are erased, and the
41
+ * tsconfig is not a module).
42
+ */
43
+ export declare const DB_TYPES_DECLARATION_FILE = "primitive-db-types.d.ts";
44
+ export declare const SDK_TYPES_FILE = "primitive-functions.d.ts";
45
+ export declare const FUNCTIONS_TSCONFIG_FILE = "tsconfig.json";
46
+ export interface DatabaseTypeSource {
47
+ databaseType: string;
48
+ tomlPath: string;
49
+ tomlContent: string;
50
+ }
51
+ /**
52
+ * The declaration for a whole config tree's database types.
53
+ *
54
+ * Sorted by type and by model so the bytes depend on the SCHEMAS and not on
55
+ * the order the files were read in — push rewrites this on every run, and
56
+ * unstable output would be a permanent diff in a developer's repository.
57
+ */
58
+ export declare function renderDbTypesDeclaration(sources: readonly DatabaseTypeSource[]): string;
59
+ /** The scaffolded compiler wiring. Written once; an author owns it after. */
60
+ export declare function renderFunctionsTsconfig(): string;
61
+ /** The bare specifier every function imports, and the tsconfig must resolve. */
62
+ export declare const SDK_MODULE_SPECIFIER = "primitive-functions";
63
+ /** What push found wrong with a `functions/tsconfig.json` it will not rewrite. */
64
+ export interface TsconfigWiringReport {
65
+ /** The document push should write, or null to leave the file as it is. */
66
+ repaired: string | null;
67
+ /**
68
+ * Wiring push could not repair, phrased for the author to act on. Empty when
69
+ * the file is fine or was repaired.
70
+ */
71
+ problems: string[];
72
+ }
73
+ /**
74
+ * Whether an existing tsconfig still carries the wiring the handle needs — the
75
+ * repaired document when push can fix it, and the problems when it cannot.
76
+ *
77
+ * The scaffold is written once and then belongs to its author, but "belongs to
78
+ * its author" cannot mean "silently stops working": a tree scaffolded before
79
+ * the `primitive-functions` rename (#3209) points at a declaration push no
80
+ * longer writes, and a tsconfig an author wrote by hand never had the wiring at
81
+ * all. Either way push claims success while no compiler can load the
82
+ * augmentation (SO3182-004).
83
+ *
84
+ * So the three REQUIRED facts — the module path mapping, the declarations being
85
+ * in the program, and the SOURCES being in the program — are repaired in a
86
+ * plain-JSON file, and everything else in it is left exactly as written. The
87
+ * mapping is APPENDED to any the author already has, so a deliberate mapping
88
+ * still wins and ours is only the fallback.
89
+ *
90
+ * A JSONC file (comments are legal in a tsconfig) is never rewritten —
91
+ * reformatting an author's file is worse than leaving it — but it IS read, and
92
+ * anything missing is reported instead of passing in silence (CR3182-003).
93
+ */
94
+ export declare function inspectFunctionsTsconfig(existing: string | null): TsconfigWiringReport;
95
+ /**
96
+ * The repaired document alone, or null to leave the file alone.
97
+ *
98
+ * Kept as the narrow answer `planFunctionTypeArtifacts` needs; the problems a
99
+ * repair cannot cover travel through `inspectFunctionsTsconfig`.
100
+ */
101
+ export declare function reconcileFunctionsTsconfig(existing: string | null): string | null;
102
+ export interface FunctionTypeArtifact {
103
+ /** Tree-relative, POSIX. */
104
+ relative: string;
105
+ absolute: string;
106
+ contents: string;
107
+ /** Generated files are rewritten every push; the scaffold is written once. */
108
+ regenerated: boolean;
109
+ }
110
+ /**
111
+ * Every database-type TOML in the tree, read once.
112
+ *
113
+ * The type KEY is the one push and the grant preflight use — `[type]
114
+ * databaseType` when the file declares it, the file name only as the fallback.
115
+ * Taking the file name unconditionally would type the handle under a key the
116
+ * platform never hears about, so `ctx.db(id, "<declared-type>")` — the key the
117
+ * grant names — would not compile while a wrong one would (SO3182-003).
118
+ */
119
+ export declare function databaseTypeSources(configDir: string): DatabaseTypeSource[];
120
+ /**
121
+ * What push would write, without writing it.
122
+ *
123
+ * Nothing at all when the tree has no `functions/` directory: the artifacts
124
+ * exist to type function sources, and a tree with none needs no compiler
125
+ * wiring.
126
+ */
127
+ export declare function planFunctionTypeArtifacts(configDir: string, sdkTypes?: string): FunctionTypeArtifact[];
128
+ /**
129
+ * The tsconfig wiring push could not repair, phrased for the author.
130
+ *
131
+ * Push repairs a plain-JSON tsconfig in place, but it will not rewrite one that
132
+ * carries comments and it cannot read one that is broken. Reporting is what is
133
+ * left, and it is not optional: a typed handle that no compiler loads is the
134
+ * failure mode this whole artifact exists to prevent, and staying silent about
135
+ * it is how it reaches an author as "my types just don't work" (CR3182-003).
136
+ */
137
+ export declare function functionTypeWiringProblems(configDir: string): string[];
138
+ /** Write them, and report the tree-relative paths that changed on disk. */
139
+ export declare function writeFunctionTypeArtifacts(configDir: string, sdkTypes?: string): string[];
140
+ /**
141
+ * The artifacts a `--check` run would rewrite: the freshness answer for CI and
142
+ * for an editor that wants to know its types are current.
143
+ *
144
+ * The tsconfig is only ever planned when it is missing or its wiring is (see
145
+ * `reconcileFunctionsTsconfig`), so a hand-edited but correctly wired one is
146
+ * never reported — and one that would leave the declarations unloadable always
147
+ * is.
148
+ */
149
+ export declare function staleFunctionTypeArtifacts(configDir: string): string[];