instant-cli 0.22.177 → 0.22.178

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 (213) hide show
  1. package/.turbo/turbo-build.log +2 -2
  2. package/__tests__/e2e/cli.e2e.test.ts +3 -3
  3. package/__tests__/e2e/helpers.ts +1 -1
  4. package/__tests__/effectHelpers.ts +45 -0
  5. package/__tests__/mergeSchema.test.ts +2 -2
  6. package/dist/commands/claim.d.ts +6 -0
  7. package/dist/commands/claim.d.ts.map +1 -0
  8. package/dist/commands/claim.js +22 -0
  9. package/dist/commands/claim.js.map +1 -0
  10. package/dist/commands/explorer.d.ts +6 -0
  11. package/dist/commands/explorer.d.ts.map +1 -0
  12. package/dist/commands/explorer.js +13 -0
  13. package/dist/commands/explorer.js.map +1 -0
  14. package/dist/commands/info.d.ts +3 -0
  15. package/dist/commands/info.d.ts.map +1 -0
  16. package/dist/commands/info.js +24 -0
  17. package/dist/commands/info.js.map +1 -0
  18. package/dist/commands/init.d.ts +5 -0
  19. package/dist/commands/init.d.ts.map +1 -0
  20. package/dist/commands/init.js +39 -0
  21. package/dist/commands/init.js.map +1 -0
  22. package/dist/commands/initWithoutFiles.d.ts +6 -0
  23. package/dist/commands/initWithoutFiles.d.ts.map +1 -0
  24. package/dist/commands/initWithoutFiles.js +64 -0
  25. package/dist/commands/initWithoutFiles.js.map +1 -0
  26. package/dist/commands/login.d.ts +9 -0
  27. package/dist/commands/login.d.ts.map +1 -0
  28. package/dist/commands/login.js +52 -0
  29. package/dist/commands/login.js.map +1 -0
  30. package/dist/commands/logout.d.ts +4 -0
  31. package/dist/commands/logout.d.ts.map +1 -0
  32. package/dist/commands/logout.js +21 -0
  33. package/dist/commands/logout.js.map +1 -0
  34. package/dist/commands/pull.d.ts +6 -0
  35. package/dist/commands/pull.d.ts.map +1 -0
  36. package/dist/commands/pull.js +16 -0
  37. package/dist/commands/pull.js.map +1 -0
  38. package/dist/commands/push.d.ts +6 -0
  39. package/dist/commands/push.d.ts.map +1 -0
  40. package/dist/commands/push.js +20 -0
  41. package/dist/commands/push.js.map +1 -0
  42. package/dist/commands/query.d.ts +7 -0
  43. package/dist/commands/query.d.ts.map +1 -0
  44. package/dist/commands/query.js +52 -0
  45. package/dist/commands/query.js.map +1 -0
  46. package/dist/context/authToken.d.ts +30 -0
  47. package/dist/context/authToken.d.ts.map +1 -0
  48. package/dist/context/authToken.js +86 -0
  49. package/dist/context/authToken.js.map +1 -0
  50. package/dist/context/currentApp.d.ts +37 -0
  51. package/dist/context/currentApp.d.ts.map +1 -0
  52. package/dist/context/currentApp.js +204 -0
  53. package/dist/context/currentApp.js.map +1 -0
  54. package/dist/context/globalOpts.d.ts +11 -0
  55. package/dist/context/globalOpts.d.ts.map +1 -0
  56. package/dist/context/globalOpts.js +13 -0
  57. package/dist/context/globalOpts.js.map +1 -0
  58. package/dist/context/platformApi.d.ts +19 -0
  59. package/dist/context/platformApi.d.ts.map +1 -0
  60. package/dist/context/platformApi.js +24 -0
  61. package/dist/context/platformApi.js.map +1 -0
  62. package/dist/context/projectInfo.d.ts +29 -0
  63. package/dist/context/projectInfo.d.ts.map +1 -0
  64. package/dist/context/projectInfo.js +149 -0
  65. package/dist/context/projectInfo.js.map +1 -0
  66. package/dist/errors.d.ts +10 -0
  67. package/dist/errors.d.ts.map +1 -0
  68. package/dist/errors.js +6 -0
  69. package/dist/errors.js.map +1 -0
  70. package/dist/index.d.ts +41 -7
  71. package/dist/index.d.ts.map +1 -1
  72. package/dist/index.js +169 -1781
  73. package/dist/index.js.map +1 -1
  74. package/dist/layer.d.ts +23 -0
  75. package/dist/layer.d.ts.map +1 -0
  76. package/dist/layer.js +68 -0
  77. package/dist/layer.js.map +1 -0
  78. package/dist/lib/createApp.d.ts +12 -0
  79. package/dist/lib/createApp.d.ts.map +1 -0
  80. package/dist/lib/createApp.js +15 -0
  81. package/dist/lib/createApp.js.map +1 -0
  82. package/dist/lib/handleEnv.d.ts +7 -0
  83. package/dist/lib/handleEnv.d.ts.map +1 -0
  84. package/dist/lib/handleEnv.js +91 -0
  85. package/dist/lib/handleEnv.js.map +1 -0
  86. package/dist/lib/http.d.ts +32 -0
  87. package/dist/lib/http.d.ts.map +1 -0
  88. package/dist/lib/http.js +67 -0
  89. package/dist/lib/http.js.map +1 -0
  90. package/dist/lib/login.d.ts +13 -0
  91. package/dist/lib/login.d.ts.map +1 -0
  92. package/dist/lib/login.js +39 -0
  93. package/dist/lib/login.js.map +1 -0
  94. package/dist/lib/pullPerms.d.ts +7 -0
  95. package/dist/lib/pullPerms.d.ts.map +1 -0
  96. package/dist/lib/pullPerms.js +41 -0
  97. package/dist/lib/pullPerms.js.map +1 -0
  98. package/dist/lib/pullSchema.d.ts +12 -0
  99. package/dist/lib/pullSchema.d.ts.map +1 -0
  100. package/dist/lib/pullSchema.js +62 -0
  101. package/dist/lib/pullSchema.js.map +1 -0
  102. package/dist/lib/pushPerms.d.ts +13 -0
  103. package/dist/lib/pushPerms.d.ts.map +1 -0
  104. package/dist/lib/pushPerms.js +54 -0
  105. package/dist/lib/pushPerms.js.map +1 -0
  106. package/dist/lib/pushSchema.d.ts +53 -0
  107. package/dist/lib/pushSchema.d.ts.map +1 -0
  108. package/dist/lib/pushSchema.js +160 -0
  109. package/dist/lib/pushSchema.js.map +1 -0
  110. package/dist/lib/ui.d.ts +16 -0
  111. package/dist/lib/ui.d.ts.map +1 -0
  112. package/dist/lib/ui.js +22 -0
  113. package/dist/lib/ui.js.map +1 -0
  114. package/dist/logging.d.ts +4 -0
  115. package/dist/logging.d.ts.map +1 -0
  116. package/dist/logging.js +17 -0
  117. package/dist/logging.js.map +1 -0
  118. package/dist/old.d.ts +14 -0
  119. package/dist/old.d.ts.map +1 -0
  120. package/dist/old.js +417 -0
  121. package/dist/old.js.map +1 -0
  122. package/dist/program.d.ts +3 -0
  123. package/dist/program.d.ts.map +1 -0
  124. package/dist/program.js +3 -0
  125. package/dist/program.js.map +1 -0
  126. package/dist/renderSchemaPlan.d.ts +3 -3
  127. package/dist/renderSchemaPlan.d.ts.map +1 -1
  128. package/dist/renderSchemaPlan.js +2 -14
  129. package/dist/renderSchemaPlan.js.map +1 -1
  130. package/dist/ui/index.d.ts +4 -3
  131. package/dist/ui/index.d.ts.map +1 -1
  132. package/dist/ui/index.js +2 -2
  133. package/dist/ui/index.js.map +1 -1
  134. package/dist/ui/lib.js +1 -0
  135. package/dist/ui/lib.js.map +1 -1
  136. package/dist/util/findConfigCandidates.d.ts +1 -1
  137. package/dist/util/findConfigCandidates.d.ts.map +1 -1
  138. package/dist/util/findConfigCandidates.js +1 -3
  139. package/dist/util/findConfigCandidates.js.map +1 -1
  140. package/dist/util/fs.d.ts +1 -1
  141. package/dist/util/fs.d.ts.map +1 -1
  142. package/dist/util/fs.js.map +1 -1
  143. package/dist/util/getAuthPaths.d.ts.map +1 -1
  144. package/dist/util/getAuthPaths.js.map +1 -1
  145. package/dist/util/isHeadlessEnvironment.d.ts +3 -1
  146. package/dist/util/isHeadlessEnvironment.d.ts.map +1 -1
  147. package/dist/util/isHeadlessEnvironment.js.map +1 -1
  148. package/dist/util/loadConfig.d.ts +1 -1
  149. package/dist/util/loadConfig.d.ts.map +1 -1
  150. package/dist/util/loadConfig.js +2 -2
  151. package/dist/util/loadConfig.js.map +1 -1
  152. package/dist/util/mergeSchema.d.ts +9 -1
  153. package/dist/util/mergeSchema.d.ts.map +1 -1
  154. package/dist/util/mergeSchema.js +4 -0
  155. package/dist/util/mergeSchema.js.map +1 -1
  156. package/dist/util/renamePrompt.d.ts +2 -1
  157. package/dist/util/renamePrompt.d.ts.map +1 -1
  158. package/dist/util/renamePrompt.js +1 -1
  159. package/dist/util/renamePrompt.js.map +1 -1
  160. package/package.json +17 -7
  161. package/src/commands/claim.ts +31 -0
  162. package/src/commands/explorer.ts +21 -0
  163. package/src/commands/info.ts +34 -0
  164. package/src/commands/init.ts +58 -0
  165. package/src/commands/initWithoutFiles.ts +107 -0
  166. package/src/commands/login.ts +76 -0
  167. package/src/commands/logout.ts +23 -0
  168. package/src/commands/pull.ts +23 -0
  169. package/src/commands/push.ts +25 -0
  170. package/src/commands/query.ts +61 -0
  171. package/src/context/authToken.ts +149 -0
  172. package/src/context/currentApp.ts +277 -0
  173. package/src/context/globalOpts.ts +22 -0
  174. package/src/context/platformApi.ts +35 -0
  175. package/src/context/projectInfo.ts +215 -0
  176. package/src/errors.ts +7 -0
  177. package/src/index.ts +428 -0
  178. package/src/layer.ts +155 -0
  179. package/src/lib/createApp.ts +28 -0
  180. package/src/lib/handleEnv.ts +115 -0
  181. package/src/lib/http.ts +148 -0
  182. package/src/lib/login.ts +54 -0
  183. package/src/lib/pullPerms.ts +50 -0
  184. package/src/lib/pullSchema.ts +95 -0
  185. package/src/lib/pushPerms.ts +80 -0
  186. package/src/lib/pushSchema.ts +240 -0
  187. package/src/lib/ui.ts +36 -0
  188. package/src/logging.ts +32 -0
  189. package/src/old.js +495 -0
  190. package/src/program.ts +3 -0
  191. package/src/renderSchemaPlan.ts +6 -18
  192. package/src/ui/index.ts +4 -3
  193. package/src/util/findConfigCandidates.ts +1 -2
  194. package/src/util/fs.ts +1 -1
  195. package/src/util/getAuthPaths.ts +1 -0
  196. package/src/util/isHeadlessEnvironment.ts +1 -1
  197. package/src/util/loadConfig.ts +3 -6
  198. package/src/util/{mergeSchema.js → mergeSchema.ts} +26 -16
  199. package/src/util/renamePrompt.ts +2 -1
  200. package/tsconfig.build.json +20 -0
  201. package/tsconfig.json +15 -5
  202. package/vitest.config.ts +2 -1
  203. package/dist/util/packageManager.d.ts +0 -3
  204. package/dist/util/packageManager.d.ts.map +0 -1
  205. package/dist/util/packageManager.js +0 -70
  206. package/dist/util/packageManager.js.map +0 -1
  207. package/dist/util/promptOk.d.ts +0 -4
  208. package/dist/util/promptOk.d.ts.map +0 -1
  209. package/dist/util/promptOk.js +0 -18
  210. package/dist/util/promptOk.js.map +0 -1
  211. package/src/index.js +0 -2333
  212. package/src/util/packageManager.js +0 -78
  213. package/src/util/promptOk.ts +0 -26
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pushSchema.d.ts","sourceRoot":"","sources":["../../src/lib/pushSchema.ts"],"names":[],"mappings":"AAeA,OAAO,EAAQ,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAMtD,OAAO,EAAE,iBAAiB,EAAe,MAAM,WAAW,CAAC;AAG3D,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACtC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAInD,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;;;;;;;AAWpD,qBAAa,mBAAoB,SAAQ,wBAKvC;CAAG;;;;;;AAEL,qBAAa,eAAgB,SAAQ,oBAInC;CAAG;;;;;;AAEL,qBAAa,cAAe,SAAQ,mBAIlC;CAAG;;;;;;AAEL,qBAAa,qBAAsB,SAAQ,0BAIzC;CAAG;AAEL,eAAO,MAAM,UAAU,GACrB,SAAS,eAAe,CAAC,OAAO,OAAO,CAAC,CAAC,QAAQ,CAAC,ifAiIhD,CAAC;;;;;;AAEL,qBAAa,gBAAiB,SAAQ,qBAIpC;CAAG;;;;AAEL,qBAAa,iBAAkB,SAAQ,uBAAsC;IAC3E,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;CAAG"}
@@ -0,0 +1,160 @@
1
+ import { HttpClient, HttpClientRequest, HttpClientResponse, } from '@effect/platform';
2
+ import { apiSchemaToInstantSchemaDef, buildAutoRenameSelector, collectSystemCatalogIdentNames, convertTxSteps, diffSchemas, SchemaValidationError as PlatformSchemaError, validateSchema, } from '@instantdb/platform';
3
+ import chalk from 'chalk';
4
+ import { Data, Effect, Schema } from 'effect';
5
+ import { CurrentApp } from "../context/currentApp.js";
6
+ import { readLocalSchemaFile, resolveRenames, waitForIndexingJobsToFinish, } from '../old.js';
7
+ import { InstantHttpAuthed, withCommand } from "./http.js";
8
+ import boxen from 'boxen';
9
+ import { GlobalOpts } from "../context/globalOpts.js";
10
+ import { pushDef } from "../index.js";
11
+ import { groupSteps, renderSchemaPlan } from "../renderSchemaPlan.js";
12
+ import { promptOk } from "./ui.js";
13
+ import { AuthToken } from "../context/authToken.js";
14
+ const FetchSchemaResponse = Schema.Struct({
15
+ schema: Schema.Struct({
16
+ refs: Schema.Any,
17
+ blobs: Schema.Any,
18
+ }),
19
+ attrs: Schema.Array(Schema.Any).pipe(Schema.mutable),
20
+ 'app-title': Schema.String,
21
+ }).pipe(Schema.mutable);
22
+ export class ReadSchemaFileError extends Schema.TaggedError('ReadSchemaFileError')('ReadSchemaFileError', {
23
+ message: Schema.String,
24
+ cause: Schema.Any.pipe(Schema.optional),
25
+ }) {
26
+ }
27
+ export class SchemaDiffError extends Schema.TaggedError('SchemaDiffError')('SchemaDiffError', {
28
+ message: Schema.String,
29
+ }) {
30
+ }
31
+ export class GetSchemaError extends Schema.TaggedError('GetSchemaError')('GetSchemaError', {
32
+ message: Schema.String,
33
+ }) {
34
+ }
35
+ export class SchemaValidationError extends Schema.TaggedError('SchemaValidationError')('SchemaValidationError', {
36
+ message: Schema.String,
37
+ }) {
38
+ }
39
+ export const pushSchema = (rename) => Effect.gen(function* () {
40
+ const localSchemaFile = yield* Effect.tryPromise({
41
+ try: readLocalSchemaFile,
42
+ catch: (e) => e instanceof Error
43
+ ? ReadSchemaFileError.make({ message: e.message })
44
+ : ReadSchemaFileError.make({ message: String(e) }),
45
+ });
46
+ if (!localSchemaFile || !localSchemaFile?.schema) {
47
+ return yield* ReadSchemaFileError.make({
48
+ message: `We couldn't find your ${chalk.yellow('`instant.schema.ts`')} file. Make sure it's in the root directory. (Hint: You can use an INSTANT_SCHEMA_FILE_PATH environment variable to specify it.)`,
49
+ });
50
+ }
51
+ if (localSchemaFile.schema?.constructor?.name !== 'InstantSchemaDef') {
52
+ return yield* SchemaValidationError.make({
53
+ message: `We couldn't find your schema export.\nIn your ${chalk.yellow('`instant.schema.ts`')} file, make sure you ${chalk.green('`export default schema`')}`,
54
+ });
55
+ }
56
+ const http = yield* InstantHttpAuthed;
57
+ const { appId } = yield* CurrentApp;
58
+ const res = yield* http
59
+ .pipe(withCommand('push'))
60
+ .get(`/dash/apps/${appId}/schema/pull`)
61
+ .pipe(Effect.andThen(HttpClientResponse.schemaBodyJson(FetchSchemaResponse)), Effect.mapError((e) => GetSchemaError.make({ message: e.message })));
62
+ const currentAttrs = res['attrs'];
63
+ const currentApiSchema = res['schema'];
64
+ const oldSchema = apiSchemaToInstantSchemaDef(currentApiSchema, {
65
+ disableTypeInference: true,
66
+ });
67
+ const systemCatalogIdentNames = collectSystemCatalogIdentNames(currentAttrs);
68
+ yield* Effect.tryPromise({
69
+ try: async () => validateSchema(localSchemaFile.schema, systemCatalogIdentNames),
70
+ catch: (e) => {
71
+ if (e instanceof PlatformSchemaError) {
72
+ return SchemaValidationError.make({
73
+ message: 'Invalid Schema: ' + e.message,
74
+ });
75
+ }
76
+ return SchemaValidationError.make({
77
+ message: 'Failed to validate schema' + e,
78
+ });
79
+ },
80
+ });
81
+ const renames = rename && Array.isArray(rename) ? rename : [];
82
+ const globalOpts = yield* GlobalOpts;
83
+ const autoRenameSelector = buildAutoRenameSelector(renames);
84
+ const renameSelector = globalOpts.yes
85
+ ? autoRenameSelector
86
+ : async (created, promptData, extraInfo) => {
87
+ const autoResolved = await autoRenameSelector(created, promptData, extraInfo);
88
+ // If the user provided an explicit --rename match, skip the prompt.
89
+ if (autoResolved !== created) {
90
+ return autoResolved;
91
+ }
92
+ return resolveRenames(created, promptData, extraInfo);
93
+ };
94
+ const diffResult = yield* Effect.tryPromise(() => diffSchemas(oldSchema, localSchemaFile.schema, renameSelector, systemCatalogIdentNames)).pipe(Effect.mapError((e) => {
95
+ if (e.cause instanceof Error) {
96
+ return SchemaDiffError.make({ message: e.cause.message });
97
+ }
98
+ return SchemaDiffError.make({ message: e.message });
99
+ }));
100
+ const txSteps = convertTxSteps(diffResult, currentAttrs);
101
+ if (txSteps.length === 0) {
102
+ yield* Effect.log(chalk.bgGray('No schema changes to apply!'));
103
+ return;
104
+ }
105
+ const groupedSteps = groupSteps(diffResult);
106
+ yield* confirmSchemaChanges(groupedSteps, currentAttrs);
107
+ const pushRes = yield* http
108
+ .pipe(HttpClient.mapRequestInputEffect(HttpClientRequest.bodyJson({
109
+ steps: txSteps,
110
+ })))
111
+ .post(`/dash/apps/${appId}/schema/steps/apply`)
112
+ .pipe(Effect.flatMap(HttpClientResponse.schemaBodyJson(Schema.Any)));
113
+ yield* Effect.log(chalk.green('Schema updated!'));
114
+ const authToken = yield* (yield* AuthToken).getAuthToken;
115
+ if (pushRes?.['indexing-jobs']) {
116
+ // TODO: rewrite in effect
117
+ yield* Effect.tryPromise({
118
+ try: () => waitForIndexingJobsToFinish(appId, pushRes?.['indexing-jobs'] || [], authToken),
119
+ catch: (e) => WaitForJobsError.make({
120
+ message: e?.message || 'Error waiting for schema push jobs to finish',
121
+ }),
122
+ });
123
+ }
124
+ });
125
+ export class WaitForJobsError extends Schema.TaggedError('WaitForJobsError')('WaitForJobsError', {
126
+ message: Schema.String,
127
+ }) {
128
+ }
129
+ export class CancelSchemaError extends Data.TaggedError('CancelSchemaError') {
130
+ }
131
+ const confirmSchemaChanges = (steps, currentAttrs) => Effect.gen(function* () {
132
+ const lines = renderSchemaPlan(steps, currentAttrs);
133
+ const globalOpts = yield* GlobalOpts;
134
+ if (globalOpts.yes) {
135
+ console.log('Applying schema changes...');
136
+ console.log(lines.join('\n'));
137
+ return;
138
+ }
139
+ const wantsToPush = yield* promptOk({
140
+ promptText: 'Push these changes?',
141
+ yesText: 'Push',
142
+ noText: 'Cancel',
143
+ modifyOutput: (output) => {
144
+ let both = lines.join('\n') + '\n\n' + output;
145
+ return boxen(both, {
146
+ dimBorder: true,
147
+ padding: {
148
+ left: 1,
149
+ right: 1,
150
+ },
151
+ });
152
+ },
153
+ });
154
+ if (!wantsToPush) {
155
+ return yield* new CancelSchemaError({
156
+ message: 'Schema Migration Cancelled',
157
+ });
158
+ }
159
+ });
160
+ //# sourceMappingURL=pushSchema.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pushSchema.js","sourceRoot":"","sources":["../../src/lib/pushSchema.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,iBAAiB,EACjB,kBAAkB,GACnB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACL,2BAA2B,EAC3B,uBAAuB,EACvB,8BAA8B,EAC9B,cAAc,EACd,WAAW,EACX,qBAAqB,IAAI,mBAAmB,EAC5C,cAAc,GACf,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,EACL,mBAAmB,EACnB,cAAc,EACd,2BAA2B,GAC5B,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAE3D,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAEtC,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAEtE,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACnC,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAEpD,MAAM,mBAAmB,GAAG,MAAM,CAAC,MAAM,CAAC;IACxC,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC;QACpB,IAAI,EAAE,MAAM,CAAC,GAAG;QAChB,KAAK,EAAE,MAAM,CAAC,GAAG;KACl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,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;QAE9B,OAAO;IACT,CAAC;IACD,MAAM,WAAW,GAAG,KAAK,CAAC,CAAC,QAAQ,CAAC;QAClC,UAAU,EAAE,qBAAqB;QACjC,OAAO,EAAE,MAAM;QACf,MAAM,EAAE,QAAQ;QAChB,YAAY,EAAE,CAAC,MAAM,EAAE,EAAE;YACvB,IAAI,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,MAAM,GAAG,MAAM,CAAC;YAC9C,OAAO,KAAK,CAAC,IAAI,EAAE;gBACjB,SAAS,EAAE,IAAI;gBACf,OAAO,EAAE;oBACP,IAAI,EAAE,CAAC;oBACP,KAAK,EAAE,CAAC;iBACT;aACF,CAAC,CAAC;QACL,CAAC;KACF,CAAC,CAAC;IACH,IAAI,CAAC,WAAW,EAAE,CAAC;QACjB,OAAO,KAAK,CAAC,CAAC,IAAI,iBAAiB,CAAC;YAClC,OAAO,EAAE,4BAA4B;SACtC,CAAC,CAAC;IACL,CAAC;AACH,CAAC,CAAC,CAAC","sourcesContent":["import {\n HttpClient,\n HttpClientRequest,\n HttpClientResponse,\n} from '@effect/platform';\nimport {\n apiSchemaToInstantSchemaDef,\n buildAutoRenameSelector,\n collectSystemCatalogIdentNames,\n convertTxSteps,\n diffSchemas,\n SchemaValidationError as PlatformSchemaError,\n validateSchema,\n} from '@instantdb/platform';\nimport chalk from 'chalk';\nimport { Data, Effect, Schema } from 'effect';\nimport { CurrentApp } from '../context/currentApp.ts';\nimport {\n readLocalSchemaFile,\n resolveRenames,\n waitForIndexingJobsToFinish,\n} from '../old.js';\nimport { InstantHttpAuthed, withCommand } from './http.ts';\n\nimport boxen from 'boxen';\nimport { GlobalOpts } from '../context/globalOpts.ts';\nimport { pushDef } from '../index.ts';\nimport type { OptsFromCommand } from '../index.ts';\nimport { groupSteps, renderSchemaPlan } from '../renderSchemaPlan.ts';\nimport type { SuperMigrationTx } from '../renderSchemaPlan.ts';\nimport { promptOk } from './ui.ts';\nimport { AuthToken } from '../context/authToken.ts';\n\nconst FetchSchemaResponse = Schema.Struct({\n schema: Schema.Struct({\n refs: Schema.Any,\n blobs: Schema.Any,\n }),\n attrs: Schema.Array(Schema.Any).pipe(Schema.mutable),\n 'app-title': Schema.String,\n}).pipe(Schema.mutable);\n\nexport class ReadSchemaFileError extends Schema.TaggedError<ReadSchemaFileError>(\n 'ReadSchemaFileError',\n)('ReadSchemaFileError', {\n message: Schema.String,\n cause: Schema.Any.pipe(Schema.optional),\n}) {}\n\nexport class SchemaDiffError extends Schema.TaggedError<SchemaDiffError>(\n 'SchemaDiffError',\n)('SchemaDiffError', {\n message: Schema.String,\n}) {}\n\nexport class GetSchemaError extends Schema.TaggedError<GetSchemaError>(\n 'GetSchemaError',\n)('GetSchemaError', {\n message: Schema.String,\n}) {}\n\nexport class SchemaValidationError extends Schema.TaggedError<SchemaValidationError>(\n 'SchemaValidationError',\n)('SchemaValidationError', {\n message: Schema.String,\n}) {}\n\nexport const pushSchema = (\n rename?: OptsFromCommand<typeof pushDef>['rename'],\n) =>\n Effect.gen(function* () {\n const localSchemaFile = yield* Effect.tryPromise({\n try: readLocalSchemaFile,\n catch: (e) =>\n e instanceof Error\n ? ReadSchemaFileError.make({ message: e.message })\n : ReadSchemaFileError.make({ message: String(e) }),\n });\n if (!localSchemaFile || !localSchemaFile?.schema) {\n return yield* ReadSchemaFileError.make({\n message: `We couldn't find your ${chalk.yellow('`instant.schema.ts`')} file. Make sure it's in the root directory. (Hint: You can use an INSTANT_SCHEMA_FILE_PATH environment variable to specify it.)`,\n });\n }\n if (localSchemaFile.schema?.constructor?.name !== 'InstantSchemaDef') {\n return yield* SchemaValidationError.make({\n message: `We couldn't find your schema export.\\nIn your ${chalk.yellow('`instant.schema.ts`')} file, make sure you ${chalk.green('`export default schema`')}`,\n });\n }\n\n const http = yield* InstantHttpAuthed;\n const { appId } = yield* CurrentApp;\n const res = yield* http\n .pipe(withCommand('push'))\n .get(`/dash/apps/${appId}/schema/pull`)\n .pipe(\n Effect.andThen(HttpClientResponse.schemaBodyJson(FetchSchemaResponse)),\n Effect.mapError((e) => GetSchemaError.make({ message: e.message })),\n );\n\n const currentAttrs = res['attrs'];\n const currentApiSchema = res['schema'];\n const oldSchema = apiSchemaToInstantSchemaDef(currentApiSchema, {\n disableTypeInference: true,\n });\n const systemCatalogIdentNames =\n collectSystemCatalogIdentNames(currentAttrs);\n\n yield* Effect.tryPromise({\n try: async () =>\n validateSchema(localSchemaFile.schema, systemCatalogIdentNames),\n catch: (e) => {\n if (e instanceof PlatformSchemaError) {\n return SchemaValidationError.make({\n message: 'Invalid Schema: ' + e.message,\n });\n }\n return SchemaValidationError.make({\n message: 'Failed to validate schema' + e,\n });\n },\n });\n const renames = rename && Array.isArray(rename) ? rename : [];\n const globalOpts = yield* GlobalOpts;\n const autoRenameSelector = buildAutoRenameSelector(renames as any);\n const renameSelector = globalOpts.yes\n ? autoRenameSelector\n : async (created: any, promptData: any, extraInfo: any) => {\n const autoResolved = await autoRenameSelector(\n created,\n promptData,\n extraInfo,\n );\n\n // If the user provided an explicit --rename match, skip the prompt.\n if (autoResolved !== created) {\n return autoResolved;\n }\n\n return resolveRenames(created, promptData, extraInfo);\n };\n\n const diffResult = yield* Effect.tryPromise(() =>\n diffSchemas(\n oldSchema,\n localSchemaFile.schema,\n renameSelector,\n systemCatalogIdentNames,\n ),\n ).pipe(\n Effect.mapError((e) => {\n if (e.cause instanceof Error) {\n return SchemaDiffError.make({ message: e.cause.message });\n }\n return SchemaDiffError.make({ message: e.message });\n }),\n );\n\n const txSteps = convertTxSteps(diffResult, currentAttrs);\n if (txSteps.length === 0) {\n yield* Effect.log(chalk.bgGray('No schema changes to apply!'));\n return;\n }\n\n const groupedSteps = groupSteps(diffResult);\n yield* confirmSchemaChanges(groupedSteps, currentAttrs);\n\n const pushRes = yield* http\n .pipe(\n HttpClient.mapRequestInputEffect(\n HttpClientRequest.bodyJson({\n steps: txSteps,\n }),\n ),\n )\n .post(`/dash/apps/${appId}/schema/steps/apply`)\n .pipe(Effect.flatMap(HttpClientResponse.schemaBodyJson(Schema.Any)));\n\n yield* Effect.log(chalk.green('Schema updated!'));\n\n const authToken = yield* (yield* AuthToken).getAuthToken;\n\n if (pushRes?.['indexing-jobs']) {\n // TODO: rewrite in effect\n yield* Effect.tryPromise({\n try: () =>\n waitForIndexingJobsToFinish(\n appId,\n pushRes?.['indexing-jobs'] || [],\n authToken,\n ),\n catch: (e: any) =>\n WaitForJobsError.make({\n message:\n e?.message || 'Error waiting for schema push jobs to finish',\n }),\n });\n }\n });\n\nexport class WaitForJobsError extends Schema.TaggedError<WaitForJobsError>(\n 'WaitForJobsError',\n)('WaitForJobsError', {\n message: Schema.String,\n}) {}\n\nexport class CancelSchemaError extends Data.TaggedError('CancelSchemaError')<{\n message: string;\n}> {}\n\nconst confirmSchemaChanges = (steps: SuperMigrationTx[], currentAttrs: any[]) =>\n Effect.gen(function* () {\n const lines = renderSchemaPlan(steps, currentAttrs);\n const globalOpts = yield* GlobalOpts;\n if (globalOpts.yes) {\n console.log('Applying schema changes...');\n console.log(lines.join('\\n'));\n\n return;\n }\n const wantsToPush = yield* promptOk({\n promptText: 'Push these changes?',\n yesText: 'Push',\n noText: 'Cancel',\n modifyOutput: (output) => {\n let both = lines.join('\\n') + '\\n\\n' + output;\n return boxen(both, {\n dimBorder: true,\n padding: {\n left: 1,\n right: 1,\n },\n });\n },\n });\n if (!wantsToPush) {\n return yield* new CancelSchemaError({\n message: 'Schema Migration Cancelled',\n });\n }\n });\n"]}
@@ -0,0 +1,16 @@
1
+ import { Effect } from 'effect';
2
+ import { GlobalOpts } from '../context/globalOpts.ts';
3
+ import { Prompt } from '../ui/lib.ts';
4
+ import { UI } from '../ui/index.ts';
5
+ declare const UIError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").Equals<A, {}> extends true ? void : { readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }) => import("effect/Cause").YieldableError & {
6
+ readonly _tag: "UIError";
7
+ } & Readonly<A>;
8
+ export declare class UIError extends UIError_base<{
9
+ message: string;
10
+ cause?: unknown;
11
+ }> {
12
+ }
13
+ export declare const promptOk: (props: UI.ConfirmationProps, defaultValue?: boolean | undefined) => Effect.Effect<boolean, never, GlobalOpts>;
14
+ export declare const runUIEffect: <P>(prompt: Prompt<P>) => Effect.Effect<P, UIError, never>;
15
+ export {};
16
+ //# sourceMappingURL=ui.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ui.d.ts","sourceRoot":"","sources":["../../src/lib/ui.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,MAAM,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,EAAE,MAAM,EAAgB,MAAM,cAAc,CAAC;AACpD,OAAO,EAAE,EAAE,EAAE,MAAM,gBAAgB,CAAC;;;;AAEpC,qBAAa,OAAQ,SAAQ,aAA4B;IACvD,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB,CAAC;CAAG;AAEL,eAAO,MAAM,QAAQ,gHAmBnB,CAAC;AAEH,eAAO,MAAM,WAAW,GAAI,CAAC,EAAE,QAAQ,MAAM,CAAC,CAAC,CAAC,qCAI5C,CAAC"}
package/dist/lib/ui.js ADDED
@@ -0,0 +1,22 @@
1
+ import { Data, Effect } from 'effect';
2
+ import { GlobalOpts } from "../context/globalOpts.js";
3
+ import { Prompt, renderUnwrap } from "../ui/lib.js";
4
+ import { UI } from "../ui/index.js";
5
+ export class UIError extends Data.TaggedError('UIError') {
6
+ }
7
+ export const promptOk = Effect.fn('promptOk')(function* (props, defaultValue = true) {
8
+ const opts = yield* GlobalOpts;
9
+ if (opts.yes) {
10
+ return defaultValue;
11
+ }
12
+ const ok = yield* Effect.tryPromise(() => renderUnwrap(new UI.Confirmation({
13
+ ...props,
14
+ defaultValue,
15
+ }))).pipe(Effect.orElseSucceed(() => defaultValue));
16
+ return ok;
17
+ });
18
+ export const runUIEffect = (prompt) => Effect.tryPromise({
19
+ try: () => renderUnwrap(prompt),
20
+ catch: (error) => new UIError({ message: 'UI Error', cause: error }),
21
+ });
22
+ //# sourceMappingURL=ui.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ui.js","sourceRoot":"","sources":["../../src/lib/ui.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EAAE,EAAE,EAAE,MAAM,gBAAgB,CAAC;AAEpC,MAAM,OAAO,OAAQ,SAAQ,IAAI,CAAC,WAAW,CAAC,SAAS,CAGrD;CAAG;AAEL,MAAM,CAAC,MAAM,QAAQ,GAAG,MAAM,CAAC,EAAE,CAAC,UAAU,CAAC,CAAC,QAAQ,CAAC,EACrD,KAA2B,EAC3B,eAAwB,IAAI;IAE5B,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,UAAU,CAAC;IAC/B,IAAI,IAAI,CAAC,GAAG,EAAE,CAAC;QACb,OAAO,YAAY,CAAC;IACtB,CAAC;IAED,MAAM,EAAE,GAAG,KAAK,CAAC,CAAC,MAAM,CAAC,UAAU,CAAC,GAAG,EAAE,CACvC,YAAY,CACV,IAAI,EAAE,CAAC,YAAY,CAAC;QAClB,GAAG,KAAK;QACR,YAAY;KACb,CAAC,CACH,CACF,CAAC,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,GAAG,EAAE,CAAC,YAAY,CAAC,CAAC,CAAC;IAEjD,OAAO,EAAE,CAAC;AACZ,CAAC,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,WAAW,GAAG,CAAI,MAAiB,EAAE,EAAE,CAClD,MAAM,CAAC,UAAU,CAAC;IAChB,GAAG,EAAE,GAAG,EAAE,CAAC,YAAY,CAAC,MAAM,CAAC;IAC/B,KAAK,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,OAAO,CAAC,EAAE,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC;CACrE,CAAC,CAAC","sourcesContent":["import { Data, Effect } from 'effect';\nimport { GlobalOpts } from '../context/globalOpts.ts';\nimport { Prompt, renderUnwrap } from '../ui/lib.ts';\nimport { UI } from '../ui/index.ts';\n\nexport class UIError extends Data.TaggedError('UIError')<{\n message: string;\n cause?: unknown;\n}> {}\n\nexport const promptOk = Effect.fn('promptOk')(function* (\n props: UI.ConfirmationProps,\n defaultValue: boolean = true,\n) {\n const opts = yield* GlobalOpts;\n if (opts.yes) {\n return defaultValue;\n }\n\n const ok = yield* Effect.tryPromise(() =>\n renderUnwrap(\n new UI.Confirmation({\n ...props,\n defaultValue,\n }),\n ),\n ).pipe(Effect.orElseSucceed(() => defaultValue));\n\n return ok;\n});\n\nexport const runUIEffect = <P>(prompt: Prompt<P>) =>\n Effect.tryPromise({\n try: () => renderUnwrap(prompt),\n catch: (error) => new UIError({ message: 'UI Error', cause: error }),\n });\n"]}
@@ -0,0 +1,4 @@
1
+ export declare function warn(firstArg: string, ...rest: any[]): void;
2
+ export declare function error(firstArg: string, ...rest: any[]): void;
3
+ export declare const SimpleLogLayer: import("effect/Layer").Layer<never, never, never>;
4
+ //# sourceMappingURL=logging.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logging.d.ts","sourceRoot":"","sources":["../src/logging.ts"],"names":[],"mappings":"AAGA,wBAAgB,IAAI,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,QAEpD;AAED,wBAAgB,KAAK,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,QAErD;AAmBD,eAAO,MAAM,cAAc,mDAG1B,CAAC"}
@@ -0,0 +1,17 @@
1
+ import chalk from 'chalk';
2
+ import { HashMap, Logger, Match, Option } from 'effect';
3
+ export function warn(firstArg, ...rest) {
4
+ console.warn(chalk.yellow('[warning]') + ' ' + firstArg, ...rest);
5
+ }
6
+ export function error(firstArg, ...rest) {
7
+ console.error(chalk.red('[error]') + ' ' + firstArg, ...rest);
8
+ }
9
+ const simpleLogger = Logger.make(({ logLevel, message, annotations }) => {
10
+ const isSilent = HashMap.get(annotations, 'silent').pipe(Option.getOrNull);
11
+ if (isSilent)
12
+ return;
13
+ const formattedMessage = Array.isArray(message) ? message.join(' ') : message;
14
+ Match.value(logLevel).pipe(Match.tag('Info', () => console.log(formattedMessage)), Match.tag('Warning', () => console.warn(formattedMessage)), Match.tag('Error', () => console.error(chalk.red('[error]') + ' ' + formattedMessage)), Match.tag('Debug', () => console.debug(formattedMessage)), Match.tag('Fatal', () => console.error(chalk.red('[error]') + ' ' + formattedMessage)));
15
+ });
16
+ export const SimpleLogLayer = Logger.replace(Logger.defaultLogger, simpleLogger);
17
+ //# sourceMappingURL=logging.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logging.js","sourceRoot":"","sources":["../src/logging.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAExD,MAAM,UAAU,IAAI,CAAC,QAAgB,EAAE,GAAG,IAAW;IACnD,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,WAAW,CAAC,GAAG,GAAG,GAAG,QAAQ,EAAE,GAAG,IAAI,CAAC,CAAC;AACpE,CAAC;AAED,MAAM,UAAU,KAAK,CAAC,QAAgB,EAAE,GAAG,IAAW;IACpD,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,SAAS,CAAC,GAAG,GAAG,GAAG,QAAQ,EAAE,GAAG,IAAI,CAAC,CAAC;AAChE,CAAC;AAED,MAAM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esContent":["import chalk from 'chalk';\nimport { HashMap, Logger, Match, Option } from 'effect';\n\nexport function warn(firstArg: string, ...rest: any[]) {\n console.warn(chalk.yellow('[warning]') + ' ' + firstArg, ...rest);\n}\n\nexport function error(firstArg: string, ...rest: any[]) {\n console.error(chalk.red('[error]') + ' ' + firstArg, ...rest);\n}\n\nconst simpleLogger = Logger.make(({ logLevel, message, annotations }) => {\n const isSilent = HashMap.get(annotations, 'silent').pipe(Option.getOrNull);\n if (isSilent) return;\n const formattedMessage = Array.isArray(message) ? message.join(' ') : message;\n Match.value(logLevel).pipe(\n Match.tag('Info', () => console.log(formattedMessage)),\n Match.tag('Warning', () => console.warn(formattedMessage)),\n Match.tag('Error', () =>\n console.error(chalk.red('[error]') + ' ' + formattedMessage),\n ),\n Match.tag('Debug', () => console.debug(formattedMessage)),\n Match.tag('Fatal', () =>\n console.error(chalk.red('[error]') + ' ' + formattedMessage),\n ),\n );\n});\n\nexport const SimpleLogLayer = Logger.replace(\n Logger.defaultLogger,\n simpleLogger,\n);\n"]}
package/dist/old.d.ts ADDED
@@ -0,0 +1,14 @@
1
+ export function waitForIndexingJobsToFinish(appId: any, data: any, authToken: any): Promise<void>;
2
+ export function readLocalPermsFile(): Promise<{
3
+ path: string;
4
+ perms: any;
5
+ } | undefined>;
6
+ export function readLocalSchemaFile(): Promise<{
7
+ path: string;
8
+ schema: any;
9
+ } | undefined>;
10
+ export function readInstantConfigFile(): Promise<any>;
11
+ export function readConfigAuthTokenWithErrorLogging(): Promise<any>;
12
+ export function countEntities(o: any): number;
13
+ export function resolveRenames(created: any, promptData: any, extraInfo: any): Promise<string | import("./util/renamePrompt.ts").RenamePromptItem<string>>;
14
+ //# sourceMappingURL=old.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"old.d.ts","sourceRoot":"","sources":["../src/old.js"],"names":[],"mappings":"AA6LA,kGAqFC;AAiID;;;eASC;AAED;;;eASC;AAED,sDAeC;AAoCD,oEAQC;AAQD,8CAEC;AA1NM,2JAoBN"}