@stoker-platform/cli 0.5.57 → 0.5.64
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.
- package/init-files/bin/build.js +1 -2
- package/init-files/functions/src/index.ts +4 -4
- package/init-files/package.json +1 -1
- package/init-files/project-data.json +1 -1
- package/init-files/src/collections/Inbox.ts +5 -5
- package/init-files/src/collections/Outbox.ts +2 -2
- package/init-files/src/main.ts +1 -1
- package/lib/package.json +4 -4
- package/lib/src/deploy/{applySchema.js → schema/applySchema.js} +2 -2
- package/lib/src/deploy/schema/updateLiveSchema.js +44 -0
- package/lib/src/lint/lintSchema.js +2 -2
- package/lib/src/lint/securityReport.js +1 -3
- package/lib/src/main.js +17 -9
- package/lib/src/project/addRecord.js +4 -1
- package/lib/src/project/addRecordPrompt.js +1 -1
- package/lib/src/project/deleteProject.js +4 -4
- package/lib/src/project/deleteRecord.js +2 -1
- package/lib/src/project/getOne.js +2 -2
- package/lib/src/project/getSome.js +4 -5
- package/lib/src/project/initProject.js +3 -1
- package/lib/src/project/updateRecord.js +4 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +4 -4
package/init-files/bin/build.js
CHANGED
|
@@ -2,10 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
import { fileURLToPath } from "url"
|
|
4
4
|
import { dirname, join } from "path"
|
|
5
|
-
import { readFile, writeFile, readdir
|
|
5
|
+
import { readFile, writeFile, readdir } from "fs/promises"
|
|
6
6
|
import { existsSync, cpSync, rmSync } from "fs"
|
|
7
7
|
import dotenv from "dotenv"
|
|
8
|
-
import { runChildProcess } from "@stoker-platform/node-client"
|
|
9
8
|
|
|
10
9
|
const envDir = join(process.cwd(), ".env")
|
|
11
10
|
const projectEnvFile = join(envDir, `.env.project.${process.env.GCP_PROJECT}`)
|
|
@@ -164,10 +164,10 @@ Object.values(schema.collections).forEach((collectionSchema) => {
|
|
|
164
164
|
const {serverWriteOnly} = access;
|
|
165
165
|
const collectionNameLower = labels.collection.toLowerCase();
|
|
166
166
|
const path = getPathCollections(collectionSchema, schema);
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
167
|
+
// eslint-disable-next-line max-len
|
|
168
|
+
const document = `tenants/{tenantId}/${path.map((collection: CollectionSchema) =>
|
|
169
|
+
`${collection.labels.collection}/{${collection.labels.record}Id}`
|
|
170
|
+
).join("/")}`;
|
|
171
171
|
|
|
172
172
|
// START CUSTOM COLLECTION LEVEL FUNCTIONS
|
|
173
173
|
|
package/init-files/package.json
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
"scripts": {
|
|
8
8
|
"clean:lib": "rm -rf lib",
|
|
9
9
|
"clean:functions": "rm -rf functions/lib",
|
|
10
|
-
"dev:assets": "npm run clean:lib && tsc && node bin/build.js && node bin/shim.js && npm --prefix functions run build && cp -r src/. web-app/src/assets/system-custom && cp lib/main.js web-app/src/assets/system-custom/main.js",
|
|
10
|
+
"dev:assets": "npm run clean:lib && tsc && node bin/build.js && node bin/shim.js && npm --prefix functions run build && npx stoker update-emulator-schema && cp -r src/. web-app/src/assets/system-custom && cp lib/main.js web-app/src/assets/system-custom/main.js",
|
|
11
11
|
"dev": "nodemon --quiet --watch src --ext ts,tsx,js,json --exec \"npm run dev:assets\"",
|
|
12
12
|
"web:dev": "cd web-app && npm run dev",
|
|
13
13
|
"prestart": "npm run build && npx stoker build-web-app && rm -rf web-app && mkdir web-app && cp -r node_modules/@stoker-platform/web-app/. web-app/ && stoker apply",
|
|
@@ -69,13 +69,13 @@ const Inbox: GenerateSchema = (sdk, utils, context): CollectionSchema => {
|
|
|
69
69
|
retentionPeriod: 7,
|
|
70
70
|
},
|
|
71
71
|
custom: {
|
|
72
|
-
async postRead(
|
|
72
|
+
async postRead({ doc }) {
|
|
73
73
|
if (sdk === "web") {
|
|
74
|
-
if (
|
|
75
|
-
toasted.push(
|
|
74
|
+
if (doc && doc.Status === "Unread" && !doc.Notified && !toasted.includes(doc.id)) {
|
|
75
|
+
toasted.push(doc.id)
|
|
76
76
|
const { updateRecord } = await import("@stoker-platform/web-client")
|
|
77
|
-
toast({ title: "New Message", description:
|
|
78
|
-
updateRecord(["Inbox"],
|
|
77
|
+
toast({ title: "New Message", description: doc.Subject, duration: 10000000 })
|
|
78
|
+
updateRecord(["Inbox"], doc.id, {
|
|
79
79
|
Notified: true,
|
|
80
80
|
})
|
|
81
81
|
}
|
|
@@ -41,12 +41,12 @@ const Outbox: GenerateSchema = (sdk: "web" | "node"): CollectionSchema => {
|
|
|
41
41
|
retentionPeriod: 7,
|
|
42
42
|
},
|
|
43
43
|
custom: {
|
|
44
|
-
async preWrite(operation, data) {
|
|
44
|
+
async preWrite({ operation, data }) {
|
|
45
45
|
if (operation === "create") {
|
|
46
46
|
data.Status = "Sending"
|
|
47
47
|
}
|
|
48
48
|
},
|
|
49
|
-
async postWrite(operation, data) {
|
|
49
|
+
async postWrite({ operation, data }) {
|
|
50
50
|
if (operation === "create") {
|
|
51
51
|
if (sdk === "web") {
|
|
52
52
|
const { addRecord, updateRecord, getCurrentUser } = await import("@stoker-platform/web-client")
|
package/init-files/src/main.ts
CHANGED
|
@@ -163,7 +163,7 @@ const globalConfig: GenerateGlobalConfig = (sdk, utils, context): GlobalConfig =
|
|
|
163
163
|
}
|
|
164
164
|
},
|
|
165
165
|
},
|
|
166
|
-
async postWriteError(operation,
|
|
166
|
+
async postWriteError({ operation, docId, context, error }) {
|
|
167
167
|
if (sdk === "web") {
|
|
168
168
|
const { sendAdminEmail } = await import("@stoker-platform/web-client")
|
|
169
169
|
const { getAuth } = await import("firebase/auth")
|
package/lib/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stoker-platform/cli",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.63",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.md",
|
|
6
6
|
"main": "./lib/src/main.js",
|
|
@@ -24,9 +24,9 @@
|
|
|
24
24
|
"@google-cloud/secret-manager": "^6.1.1",
|
|
25
25
|
"@google-cloud/storage": "^7.19.0",
|
|
26
26
|
"@inquirer/prompts": "^8.3.2",
|
|
27
|
-
"@stoker-platform/node-client": "0.5.
|
|
28
|
-
"@stoker-platform/types": "0.5.
|
|
29
|
-
"@stoker-platform/utils": "0.5.
|
|
27
|
+
"@stoker-platform/node-client": "0.5.46",
|
|
28
|
+
"@stoker-platform/types": "0.5.29",
|
|
29
|
+
"@stoker-platform/utils": "0.5.38",
|
|
30
30
|
"algoliasearch": "^5.50.0",
|
|
31
31
|
"commander": "^14.0.0",
|
|
32
32
|
"cross-spawn": "^7.0.6",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { runChildProcess } from "@stoker-platform/node-client";
|
|
2
|
-
import { getFunctionsData } from "
|
|
3
|
-
import { generateSchema } from "
|
|
2
|
+
import { getFunctionsData } from "../cloud-functions/getFunctionsData.js";
|
|
3
|
+
import { generateSchema } from "../schema/generateSchema.js";
|
|
4
4
|
import { readdir, readFile, writeFile } from "fs/promises";
|
|
5
5
|
import { join } from "path";
|
|
6
6
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { initializeFirebase, runChildProcess } from "@stoker-platform/node-client";
|
|
2
|
+
import { getFunctionsData } from "../cloud-functions/getFunctionsData.js";
|
|
3
|
+
import { generateSchema } from "../schema/generateSchema.js";
|
|
4
|
+
import { readFile } from "fs/promises";
|
|
5
|
+
import { join } from "path";
|
|
6
|
+
import { getDatabase } from "firebase-admin/database";
|
|
7
|
+
const DEFAULT_RTDB_PORT = 9000;
|
|
8
|
+
const getEmulatorHost = async () => {
|
|
9
|
+
const firebaseConfigString = await readFile(join(process.cwd(), "firebase.json"), "utf8");
|
|
10
|
+
const firebaseConfig = JSON.parse(firebaseConfigString);
|
|
11
|
+
const port = firebaseConfig?.emulators?.database?.port ?? DEFAULT_RTDB_PORT;
|
|
12
|
+
return `127.0.0.1:${port}`;
|
|
13
|
+
};
|
|
14
|
+
const isEmulatorRunning = async (host) => {
|
|
15
|
+
try {
|
|
16
|
+
const response = await fetch(`http://${host}/.json?shallow=true`);
|
|
17
|
+
return response.ok;
|
|
18
|
+
}
|
|
19
|
+
catch {
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
24
|
+
export const updateLiveSchema = async () => {
|
|
25
|
+
try {
|
|
26
|
+
const schema = await generateSchema(true);
|
|
27
|
+
await initializeFirebase();
|
|
28
|
+
const emulatorHost = await getEmulatorHost();
|
|
29
|
+
process.env.FIREBASE_DATABASE_EMULATOR_HOST = emulatorHost;
|
|
30
|
+
const updateEmulatorData = await isEmulatorRunning(emulatorHost);
|
|
31
|
+
if (updateEmulatorData) {
|
|
32
|
+
const rtdb = getDatabase();
|
|
33
|
+
const ref = rtdb.ref("schema").child("1");
|
|
34
|
+
await ref.set(schema);
|
|
35
|
+
}
|
|
36
|
+
await getFunctionsData();
|
|
37
|
+
await runChildProcess("npx", ["stoker", "generate-firestore-rules"]);
|
|
38
|
+
await runChildProcess("npx", ["stoker", "generate-storage-rules"]);
|
|
39
|
+
process.exit();
|
|
40
|
+
}
|
|
41
|
+
catch (error) {
|
|
42
|
+
throw new Error("Error applying schema.", { cause: error });
|
|
43
|
+
}
|
|
44
|
+
};
|
|
@@ -1489,12 +1489,12 @@ export const lintSchema = async (noLog = false) => {
|
|
|
1489
1489
|
if (filter.roles && !filter.roles.includes(role))
|
|
1490
1490
|
continue;
|
|
1491
1491
|
if (filter.type === "relation" && hasArrayContains) {
|
|
1492
|
-
errors.push(`Collection ${collectionName} has a relation filter for role ${role} on field ${filter.field} that uses an array
|
|
1492
|
+
errors.push(`Collection ${collectionName} has a relation filter for role ${role} on field ${filter.field} that uses an array-contains filter, but an array-contains filter has already been used. This can be resolved by using the preload cache.`);
|
|
1493
1493
|
}
|
|
1494
1494
|
if (filter.type === "select") {
|
|
1495
1495
|
const field = getField(fields, filter.field);
|
|
1496
1496
|
if (field.type === "Array" && hasArrayContains) {
|
|
1497
|
-
errors.push(`Collection ${collectionName} has a select filter for role ${role} on field ${filter.field} that uses an array
|
|
1497
|
+
errors.push(`Collection ${collectionName} has a select filter for role ${role} on field ${filter.field} that uses an array-contains filter, but an array-contains filter has already been used. This can be resolved by using the preload cache.`);
|
|
1498
1498
|
}
|
|
1499
1499
|
}
|
|
1500
1500
|
}
|
|
@@ -59,9 +59,7 @@ export const securityReport = async () => {
|
|
|
59
59
|
roles[role] = {};
|
|
60
60
|
for (const [collectionName, collectionSchema] of Object.entries(schema.collections)) {
|
|
61
61
|
const { fields, access } = collectionSchema;
|
|
62
|
-
if (access.operations.
|
|
63
|
-
(typeof access.operations.assignable === "object" && access.operations.assignable.includes(role)) ||
|
|
64
|
-
access.operations.read?.includes(role)) {
|
|
62
|
+
if (access.operations.read?.includes(role)) {
|
|
65
63
|
for (const field of fields) {
|
|
66
64
|
if (field.access)
|
|
67
65
|
continue;
|
package/lib/src/main.js
CHANGED
|
@@ -80,9 +80,10 @@ import { auditDenormalized } from "./ops/auditDenormalized.js";
|
|
|
80
80
|
import { auditRelations } from "./ops/auditRelations.js";
|
|
81
81
|
import { listProjects } from "./ops/listProjects.js";
|
|
82
82
|
import { customDomain } from "./project/customDomain.js";
|
|
83
|
-
import { applySchema } from "./deploy/applySchema.js";
|
|
83
|
+
import { applySchema } from "./deploy/schema/applySchema.js";
|
|
84
84
|
import { addTenant } from "./project/addTenant.js";
|
|
85
85
|
import { deleteTenant } from "./project/deleteTenant.js";
|
|
86
|
+
import { updateLiveSchema } from "./deploy/schema/updateLiveSchema.js";
|
|
86
87
|
const program = new Command();
|
|
87
88
|
program.name("stoker").description("Stoker Platform CLI").version(pkg.version);
|
|
88
89
|
program
|
|
@@ -218,6 +219,12 @@ program
|
|
|
218
219
|
.action(() => {
|
|
219
220
|
applySchema();
|
|
220
221
|
});
|
|
222
|
+
program
|
|
223
|
+
.command("update-emulator-schema")
|
|
224
|
+
.description("update emulator schema")
|
|
225
|
+
.action(() => {
|
|
226
|
+
updateLiveSchema();
|
|
227
|
+
});
|
|
221
228
|
program
|
|
222
229
|
.command("migrate")
|
|
223
230
|
.description("migrate the database")
|
|
@@ -299,7 +306,7 @@ program
|
|
|
299
306
|
.description("add a record")
|
|
300
307
|
.option("-m, --mode <mode>", "development / production")
|
|
301
308
|
.requiredOption("-t, --tenant <tenant>", "the tenant to add the record to")
|
|
302
|
-
.requiredOption("-p, --path <path>", "the path
|
|
309
|
+
.requiredOption("-p, --path <path>", "the path to the record's collection")
|
|
303
310
|
.requiredOption("-d, --data <data>", "the data to add")
|
|
304
311
|
.option("-a, --user-data <user>", "data for creating a user")
|
|
305
312
|
.option("-u, --user <user>", "the ID of the user to add the record as")
|
|
@@ -323,8 +330,8 @@ program
|
|
|
323
330
|
.description("update a record")
|
|
324
331
|
.option("-m, --mode <mode>", "development / production")
|
|
325
332
|
.requiredOption("-t, --tenant <tenant>", "the tenant of the record")
|
|
326
|
-
.requiredOption("-p, --path <path>", "the path
|
|
327
|
-
.requiredOption("-i, --id <id>", "the ID of the
|
|
333
|
+
.requiredOption("-p, --path <path>", "the path to the record's collection")
|
|
334
|
+
.requiredOption("-i, --id <id>", "the ID of the record")
|
|
328
335
|
.requiredOption("-d, --data <data>", "the data to update")
|
|
329
336
|
.option("-a, --user-data <user>", "data for creating, updating or deleting a user")
|
|
330
337
|
.option("-u, --user <user>", "the ID of the user to update the record as")
|
|
@@ -336,8 +343,8 @@ program
|
|
|
336
343
|
.description("delete a record")
|
|
337
344
|
.option("-m, --mode <mode>", "development / production")
|
|
338
345
|
.requiredOption("-t, --tenant <tenant>", "the tenant of the record")
|
|
339
|
-
.requiredOption("-p, --path <path>", "the path
|
|
340
|
-
.requiredOption("-i, --id <id>", "the ID of the
|
|
346
|
+
.requiredOption("-p, --path <path>", "the path to the record's collection")
|
|
347
|
+
.requiredOption("-i, --id <id>", "the ID of the record")
|
|
341
348
|
.option("-u, --user <user>", "the ID of the user to delete the record as")
|
|
342
349
|
.option("-f, --force", "force deletion of a record with soft delete enabled")
|
|
343
350
|
.action((options) => {
|
|
@@ -348,7 +355,8 @@ program
|
|
|
348
355
|
.description("get a record")
|
|
349
356
|
.option("-m, --mode <mode>", "development / production")
|
|
350
357
|
.requiredOption("-t, --tenant <tenant>", "the tenant of the record")
|
|
351
|
-
.requiredOption("-p, --path <path>", "the path
|
|
358
|
+
.requiredOption("-p, --path <path>", "the path to the record's collection")
|
|
359
|
+
.requiredOption("-i, --id <id>", "the ID of the record")
|
|
352
360
|
.option("-r, --relations <depth>", "retrieve relations at the specified depth")
|
|
353
361
|
.option("-s, --subcollections <depth>", "retrieve subcollections at the specified depth")
|
|
354
362
|
.option("-u, --user <user>", "the ID of the user to get the record as")
|
|
@@ -360,8 +368,8 @@ program
|
|
|
360
368
|
.description("get multiple records")
|
|
361
369
|
.option("-m, --mode <mode>", "development / production")
|
|
362
370
|
.requiredOption("-t, --tenant <tenant>", "the tenant of the records")
|
|
363
|
-
.requiredOption("-p, --path <path>", "the path
|
|
364
|
-
.option("-c, --constraints <constraints>", "
|
|
371
|
+
.requiredOption("-p, --path <path>", "the path to the collection")
|
|
372
|
+
.option("-c, --constraints <constraints>", "constraints to apply to the query")
|
|
365
373
|
.option("-r, --relations <depth>", "retrieve relations at the specified depth")
|
|
366
374
|
.option("-s, --subcollections <depth>", "retrieve subcollections at the specified depth")
|
|
367
375
|
.option("-u, --user <user>", "the ID of the user to get the records as")
|
|
@@ -3,7 +3,10 @@ import { join } from "path";
|
|
|
3
3
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
4
4
|
export const addRecord = async (options) => {
|
|
5
5
|
await initializeStoker(options.mode || "production", options.tenant, join(process.cwd(), "lib", "main.js"), join(process.cwd(), "lib", "collections"));
|
|
6
|
-
const result = await addStokerRecord(options.path.split("/"), JSON.parse(options.data),
|
|
6
|
+
const result = await addStokerRecord(options.path.split("/"), JSON.parse(options.data), {
|
|
7
|
+
userId: options.user,
|
|
8
|
+
user: options.userData ? JSON.parse(options.userData) : undefined,
|
|
9
|
+
});
|
|
7
10
|
console.log(JSON.stringify(result, null, 2));
|
|
8
11
|
process.exit();
|
|
9
12
|
};
|
|
@@ -199,7 +199,7 @@ export const addRecordPrompt = async (tenantId, collectionName, fullAccess, mode
|
|
|
199
199
|
delete record[fieldName];
|
|
200
200
|
}
|
|
201
201
|
}
|
|
202
|
-
const result = await addRecord([labels.collection], record, user);
|
|
202
|
+
const result = await addRecord([labels.collection], record, { user });
|
|
203
203
|
console.log(result);
|
|
204
204
|
return result;
|
|
205
205
|
};
|
|
@@ -10,13 +10,13 @@ export const deleteProject = async (options) => {
|
|
|
10
10
|
throw new Error("Error deleting project.");
|
|
11
11
|
});
|
|
12
12
|
console.log("Project deleted.");
|
|
13
|
+
const projectData = JSON.parse(await readFile(join(process.cwd(), "project-data.json"), "utf8"));
|
|
14
|
+
delete projectData.projects[process.env.GCP_PROJECT];
|
|
13
15
|
if (!options.testMode) {
|
|
14
|
-
const projectData = JSON.parse(await readFile(join(process.cwd(), "project-data.json"), "utf8"));
|
|
15
|
-
delete projectData.projects[process.env.GCP_PROJECT];
|
|
16
16
|
projectData.deleted_projects.push(process.env.GCP_PROJECT);
|
|
17
|
-
await writeFile(join(process.cwd(), "project-data.json"), JSON.stringify(projectData, null, 4));
|
|
18
|
-
console.log("Project deleted from project data.");
|
|
19
17
|
}
|
|
18
|
+
await writeFile(join(process.cwd(), "project-data.json"), JSON.stringify(projectData, null, 4));
|
|
19
|
+
console.log("Project deleted from project data.");
|
|
20
20
|
// eslint-disable-next-line security/detect-non-literal-fs-filename
|
|
21
21
|
if (existsSync(join(process.cwd(), ".env", `.env.${process.env.GCP_PROJECT}`))) {
|
|
22
22
|
// eslint-disable-next-line security/detect-non-literal-fs-filename
|
|
@@ -3,7 +3,8 @@ import { join } from "path";
|
|
|
3
3
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
4
4
|
export const deleteRecord = async (options) => {
|
|
5
5
|
await initializeStoker(options.mode || "production", options.tenant, join(process.cwd(), "lib", "main.js"), join(process.cwd(), "lib", "collections"));
|
|
6
|
-
const deletedRecord = await deleteStokerRecord(options.path.split("/"), options.id,
|
|
6
|
+
const deletedRecord = await deleteStokerRecord(options.path.split("/"), options.id, {
|
|
7
|
+
userId: options.user,
|
|
7
8
|
force: options.force,
|
|
8
9
|
});
|
|
9
10
|
console.log(JSON.stringify(deletedRecord, null, 2));
|
|
@@ -4,7 +4,7 @@ import { join } from "path";
|
|
|
4
4
|
export const getOne = async (options) => {
|
|
5
5
|
await initializeStoker(options.mode || "production", options.tenant, join(process.cwd(), "lib", "main.js"), join(process.cwd(), "lib", "collections"));
|
|
6
6
|
const path = options.path.split("/");
|
|
7
|
-
const id =
|
|
7
|
+
const id = options.id;
|
|
8
8
|
const getOneOptions = {};
|
|
9
9
|
if (options.subcollections) {
|
|
10
10
|
getOneOptions.subcollections = {
|
|
@@ -17,7 +17,7 @@ export const getOne = async (options) => {
|
|
|
17
17
|
};
|
|
18
18
|
}
|
|
19
19
|
if (options.user) {
|
|
20
|
-
getOneOptions.
|
|
20
|
+
getOneOptions.userId = options.user;
|
|
21
21
|
}
|
|
22
22
|
const result = await getOneStoker(path, id, getOneOptions);
|
|
23
23
|
console.log(JSON.stringify(result, null, 2));
|
|
@@ -4,11 +4,10 @@ import { join } from "path";
|
|
|
4
4
|
export const getSome = async (options) => {
|
|
5
5
|
await initializeStoker(options.mode || "production", options.tenant, join(process.cwd(), "lib", "main.js"), join(process.cwd(), "lib", "collections"));
|
|
6
6
|
const path = options.path.split("/");
|
|
7
|
-
|
|
7
|
+
const getSomeOptions = {};
|
|
8
8
|
if (options.constraints) {
|
|
9
|
-
constraints = JSON.parse(options.constraints);
|
|
9
|
+
getSomeOptions.constraints = JSON.parse(options.constraints);
|
|
10
10
|
}
|
|
11
|
-
const getSomeOptions = {};
|
|
12
11
|
if (options.subcollections) {
|
|
13
12
|
getSomeOptions.subcollections = {
|
|
14
13
|
depth: options.subcollections,
|
|
@@ -20,9 +19,9 @@ export const getSome = async (options) => {
|
|
|
20
19
|
};
|
|
21
20
|
}
|
|
22
21
|
if (options.user) {
|
|
23
|
-
getSomeOptions.
|
|
22
|
+
getSomeOptions.userId = options.user;
|
|
24
23
|
}
|
|
25
|
-
const result = await getSomeStoker(path,
|
|
24
|
+
const result = await getSomeStoker(path, getSomeOptions);
|
|
26
25
|
console.log(JSON.stringify(result.docs, null, 2));
|
|
27
26
|
process.exit();
|
|
28
27
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { fileURLToPath } from "url";
|
|
2
2
|
import { resolve, dirname, join } from "path";
|
|
3
|
-
import { existsSync, cpSync, renameSync } from "fs";
|
|
3
|
+
import { existsSync, cpSync, renameSync, mkdirSync } from "fs";
|
|
4
4
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
5
5
|
export const initProject = async (options) => {
|
|
6
6
|
if (existsSync("firebase.json") && !options.force) {
|
|
@@ -12,5 +12,7 @@ export const initProject = async (options) => {
|
|
|
12
12
|
cpSync(resolve(__dirname, "..", "..", "..", "init-files"), process.cwd(), { recursive: true });
|
|
13
13
|
renameSync(join(process.cwd(), ".##gitignore##"), join(process.cwd(), ".gitignore"));
|
|
14
14
|
renameSync(join(process.cwd(), "functions", ".##gitignore##"), join(process.cwd(), "functions", ".gitignore"));
|
|
15
|
+
mkdirSync(join(process.cwd(), ".migration"));
|
|
16
|
+
mkdirSync(join(process.cwd(), "firebase-emulator-data"));
|
|
15
17
|
process.exit();
|
|
16
18
|
};
|
|
@@ -3,7 +3,10 @@ import { join } from "path";
|
|
|
3
3
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
4
4
|
export const updateRecord = async (options) => {
|
|
5
5
|
await initializeStoker(options.mode || "production", options.tenant, join(process.cwd(), "lib", "main.js"), join(process.cwd(), "lib", "collections"));
|
|
6
|
-
const updatedRecord = await updateStokerRecord(options.path.split("/"), options.id, JSON.parse(options.data),
|
|
6
|
+
const updatedRecord = await updateStokerRecord(options.path.split("/"), options.id, JSON.parse(options.data), {
|
|
7
|
+
userId: options.user,
|
|
8
|
+
user: options.userData ? JSON.parse(options.userData) : undefined,
|
|
9
|
+
});
|
|
7
10
|
console.log(JSON.stringify(updatedRecord, null, 2));
|
|
8
11
|
process.exit();
|
|
9
12
|
};
|
package/lib/tsconfig.tsbuildinfo
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"root":["../src/main.ts","../src/data/exporttobigquery.ts","../src/data/seeddata.ts","../src/deploy/
|
|
1
|
+
{"root":["../src/main.ts","../src/data/exporttobigquery.ts","../src/data/seeddata.ts","../src/deploy/deployproject.ts","../src/deploy/cloud-functions/getfunctionsdata.ts","../src/deploy/firestore-export/exportfirestoredata.ts","../src/deploy/firestore-ttl/deployttls.ts","../src/deploy/live-update/liveupdate.ts","../src/deploy/maintenance/activatemaintenancemode.ts","../src/deploy/maintenance/disablemaintenancemode.ts","../src/deploy/maintenance/setdeploymentstatus.ts","../src/deploy/rules-indexes/generatefirestoreindexes.ts","../src/deploy/rules-indexes/generatefirestorerules.ts","../src/deploy/rules-indexes/generatestoragerules.ts","../src/deploy/schema/applyschema.ts","../src/deploy/schema/generateschema.ts","../src/deploy/schema/persistschema.ts","../src/deploy/schema/updateliveschema.ts","../src/lint/lintschema.ts","../src/lint/securityreport.ts","../src/migration/migrateall.ts","../src/migration/firestore/migratefirestore.ts","../src/migration/firestore/operations/deletefield.ts","../src/ops/auditdenormalized.ts","../src/ops/auditpermissions.ts","../src/ops/auditrelations.ts","../src/ops/explainpreloadqueries.ts","../src/ops/getuser.ts","../src/ops/getuserpermissions.ts","../src/ops/getuserrecord.ts","../src/ops/listprojects.ts","../src/ops/setusercollection.ts","../src/ops/setuserdocument.ts","../src/ops/setuserrole.ts","../src/project/addproject.ts","../src/project/addrecord.ts","../src/project/addrecordprompt.ts","../src/project/addtenant.ts","../src/project/buildwebapp.ts","../src/project/customdomain.ts","../src/project/deleteproject.ts","../src/project/deleterecord.ts","../src/project/deletetenant.ts","../src/project/getone.ts","../src/project/getsome.ts","../src/project/initproject.ts","../src/project/prepareemulatordata.ts","../src/project/setproject.ts","../src/project/startemulators.ts","../src/project/updaterecord.ts"],"version":"6.0.2"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stoker-platform/cli",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.64",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.md",
|
|
6
6
|
"main": "./lib/src/main.js",
|
|
@@ -24,9 +24,9 @@
|
|
|
24
24
|
"@google-cloud/secret-manager": "^6.1.1",
|
|
25
25
|
"@google-cloud/storage": "^7.19.0",
|
|
26
26
|
"@inquirer/prompts": "^8.3.2",
|
|
27
|
-
"@stoker-platform/node-client": "0.5.
|
|
28
|
-
"@stoker-platform/types": "0.5.
|
|
29
|
-
"@stoker-platform/utils": "0.5.
|
|
27
|
+
"@stoker-platform/node-client": "0.5.46",
|
|
28
|
+
"@stoker-platform/types": "0.5.29",
|
|
29
|
+
"@stoker-platform/utils": "0.5.38",
|
|
30
30
|
"algoliasearch": "^5.50.0",
|
|
31
31
|
"commander": "^14.0.0",
|
|
32
32
|
"cross-spawn": "^7.0.6",
|