@stoker-platform/cli 0.5.65 → 0.5.68

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.
@@ -16,7 +16,7 @@ import { parseDate } from "@stoker-platform/utils"
16
16
 
17
17
  const toasted: string[] = []
18
18
 
19
- const Inbox: GenerateSchema = (sdk, utils, context): CollectionSchema => {
19
+ const Inbox: GenerateSchema = ({ sdk, utils, context }): CollectionSchema => {
20
20
  const { toast } = (context || {}) as {
21
21
  toast: ({
22
22
  title,
@@ -69,13 +69,13 @@ const Inbox: GenerateSchema = (sdk, utils, context): CollectionSchema => {
69
69
  retentionPeriod: 7,
70
70
  },
71
71
  custom: {
72
- async postRead({ doc }) {
72
+ async postRead({ record }) {
73
73
  if (sdk === "web") {
74
- if (doc && doc.Status === "Unread" && !doc.Notified && !toasted.includes(doc.id)) {
75
- toasted.push(doc.id)
74
+ if (record && record.Status === "Unread" && !record.Notified && !toasted.includes(record.id)) {
75
+ toasted.push(record.id)
76
76
  const { updateRecord } = await import("@stoker-platform/web-client")
77
- toast({ title: "New Message", description: doc.Subject, duration: 10000000 })
78
- updateRecord(["Inbox"], doc.id, {
77
+ toast({ title: "New Message", description: record.Subject, duration: 10000000 })
78
+ updateRecord(["Inbox"], record.id, {
79
79
  Notified: true,
80
80
  })
81
81
  }
@@ -3,7 +3,7 @@ import { MessageCircle, Send, SquarePen, Timer, TrendingUp, Users } from "lucide
3
3
  import { blueField, greenField, redField } from "../utils.js"
4
4
  import { parseDate } from "@stoker-platform/utils"
5
5
 
6
- const Outbox: GenerateSchema = (sdk: "web" | "node"): CollectionSchema => {
6
+ const Outbox: GenerateSchema = ({ sdk }): CollectionSchema => {
7
7
  return {
8
8
  labels: {
9
9
  collection: "Outbox",
@@ -1,6 +1,6 @@
1
1
  import type { DialogContent, GenerateGlobalConfig, GlobalConfig, WebUtilities } from "@stoker-platform/types"
2
2
 
3
- const globalConfig: GenerateGlobalConfig = (sdk, utils, context): GlobalConfig => {
3
+ const globalConfig: GenerateGlobalConfig = ({ sdk, utils, context }): GlobalConfig => {
4
4
  const { setDialogContent, setConnectionStatus } = (context || {}) as {
5
5
  setDialogContent: (dialogContent: DialogContent | null) => void
6
6
  setConnectionStatus: (connectionStatus: "online" | "offline") => void
@@ -163,7 +163,7 @@ const globalConfig: GenerateGlobalConfig = (sdk, utils, context): GlobalConfig =
163
163
  }
164
164
  },
165
165
  },
166
- async postWriteError({ operation, docId, context, error }) {
166
+ async postWriteError({ operation, recordId, 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")
@@ -171,7 +171,7 @@ const globalConfig: GenerateGlobalConfig = (sdk, utils, context): GlobalConfig =
171
171
  if (!currentUser?.uid) throw new Error("Error sending Firestore write operation failure email")
172
172
  await sendAdminEmail(
173
173
  `Stoker Operation Failure`,
174
- `Operation Type: ${operation}\n\nUser: ${currentUser.displayName}\n\nUser ID: ${currentUser.uid}\n\nCollection: ${context.collection}\n\nDocument ID: ${docId}\n\nError Details:\n\n${JSON.stringify(error)}`,
174
+ `Operation Type: ${operation}\n\nUser: ${currentUser.displayName}\n\nUser ID: ${currentUser.uid}\n\nCollection: ${context.collection}\n\nDocument ID: ${recordId}\n\nError Details:\n\n${JSON.stringify(error)}`,
175
175
  ).catch(() => {
176
176
  throw new Error("Error sending Firestore write operation failure email")
177
177
  })
package/lib/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stoker-platform/cli",
3
- "version": "0.5.64",
3
+ "version": "0.5.67",
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.4.2",
27
- "@stoker-platform/node-client": "0.5.46",
28
- "@stoker-platform/types": "0.5.29",
29
- "@stoker-platform/utils": "0.5.38",
27
+ "@stoker-platform/node-client": "0.5.48",
28
+ "@stoker-platform/types": "0.5.31",
29
+ "@stoker-platform/utils": "0.5.40",
30
30
  "algoliasearch": "^5.51.0",
31
31
  "commander": "^14.0.0",
32
32
  "cross-spawn": "^7.0.6",
@@ -9,7 +9,7 @@ export const getFunctionsData = async () => {
9
9
  const url = pathToFileURL(path).href;
10
10
  const globalConfigFile = await import(/* @vite-ignore */ url);
11
11
  const config = globalConfigFile.default;
12
- const globalConfig = config("node");
12
+ const globalConfig = config({ sdk: "node" });
13
13
  const timezone = await tryPromise(globalConfig.timezone);
14
14
  const schema = await generateSchema();
15
15
  const filePath = join(process.cwd(), "functions", "project-data.json");
@@ -10,7 +10,7 @@ export const generateSchema = async (includeComputedFields = false) => {
10
10
  const path = join(process.cwd(), "lib", "main.js");
11
11
  const url = pathToFileURL(path).href;
12
12
  const globalConfigFile = await import(url);
13
- const globalConfig = globalConfigFile.default("node");
13
+ const globalConfig = globalConfigFile.default({ sdk: "node" });
14
14
  const projectData = await readFile(join(process.cwd(), "project-data.json"), "utf8");
15
15
  const projectDataJson = JSON.parse(projectData);
16
16
  const version = projectDataJson.version || 1;
@@ -36,7 +36,7 @@ export const generateSchema = async (includeComputedFields = false) => {
36
36
  const path = join(process.cwd(), "lib", "collections", collection);
37
37
  const url = pathToFileURL(path).href;
38
38
  const schema = await import(url);
39
- fullSchema.push(schema.default("node"));
39
+ fullSchema.push(schema.default({ sdk: "node" }));
40
40
  }
41
41
  newSchema.collections = {};
42
42
  for (const collection of collections) {
@@ -45,7 +45,7 @@ export const generateSchema = async (includeComputedFields = false) => {
45
45
  const path = join(process.cwd(), "lib", "collections", collection);
46
46
  const url = pathToFileURL(path).href;
47
47
  const schema = await import(url);
48
- const persistSchema = schema.default("node");
48
+ const persistSchema = schema.default({ sdk: "node" });
49
49
  const { labels, access, preloadCache, admin } = persistSchema;
50
50
  const { serverReadOnly } = access;
51
51
  if (!includeComputedFields) {
@@ -7,7 +7,7 @@ export const lintSchema = async (noLog = false) => {
7
7
  const path = join(process.cwd(), "lib", "main.js");
8
8
  const url = pathToFileURL(path).href;
9
9
  const globalConfigFile = await import(url);
10
- const globalConfig = globalConfigFile.default("node");
10
+ const globalConfig = globalConfigFile.default({ sdk: "node" });
11
11
  const schema = await generateSchema(true);
12
12
  const customizationFiles = await getCustomizationFiles(join(process.cwd(), "lib", "collections"), Object.keys(schema.collections));
13
13
  const customizationModules = getCustomization(Object.keys(schema.collections), customizationFiles, "node");
@@ -13,7 +13,7 @@ export const securityReport = async () => {
13
13
  const path = join(process.cwd(), "lib", "main.js");
14
14
  const url = pathToFileURL(path).href;
15
15
  const globalConfigFile = await import(url);
16
- const globalConfig = globalConfigFile.default("node");
16
+ const globalConfig = globalConfigFile.default({ sdk: "node" });
17
17
  for (const [collectionName, collectionSchema] of Object.entries(schema.collections)) {
18
18
  const { auth, fields, access } = collectionSchema;
19
19
  const { serverWriteOnly } = access;
@@ -66,7 +66,7 @@ export const securityReport = async () => {
66
66
  const path = join(process.cwd(), "lib", "collections", `${collectionName}.js`);
67
67
  const url = pathToFileURL(path).href;
68
68
  const customizationFile = await import(url);
69
- const customization = customizationFile.default("node");
69
+ const customization = customizationFile.default({ sdk: "node" });
70
70
  if (isRelationField(field)) {
71
71
  const relationCollection = schema.collections[field.collection];
72
72
  const relationAccess = relationCollection.access;
@@ -829,7 +829,7 @@ export const addProject = async (options) => {
829
829
  recaptchaKeyId = recaptchaKey.split("/").pop();
830
830
  await updateProjectData(35);
831
831
  }
832
- if (getProgress() < 36) {
832
+ const getRecaptchaKeyId = async () => {
833
833
  if (!recaptchaKeyId) {
834
834
  const listKeysResponse = await fetch(`https://recaptchaenterprise.googleapis.com/v1/projects/${projectId}/keys?pageSize=100`, {
835
835
  method: "GET",
@@ -850,6 +850,10 @@ export const addProject = async (options) => {
850
850
  throw new Error("Failed to recover Recaptcha key ID");
851
851
  }
852
852
  }
853
+ return recaptchaKeyId;
854
+ };
855
+ if (getProgress() < 36) {
856
+ recaptchaKeyId = await getRecaptchaKeyId();
853
857
  const recaptchaEnterpriseConfig = await fetch(`https://firebaseappcheck.googleapis.com/v1beta/projects/${projectId}/apps/${appId}/recaptchaEnterpriseConfig?updateMask=siteKey,tokenTtl,riskAnalysis`, {
854
858
  method: "PATCH",
855
859
  headers: {
@@ -931,6 +935,9 @@ export const addProject = async (options) => {
931
935
  }
932
936
  await updateProjectData(37);
933
937
  }
938
+ if (!recaptchaKeyId) {
939
+ recaptchaKeyId = await getRecaptchaKeyId();
940
+ }
934
941
  const firebaseJson = JSON.parse(await readFile(join(process.cwd(), "firebase.json"), "utf8"));
935
942
  const authPort = firebaseJson.emulators.auth.port;
936
943
  const databasePort = firebaseJson.emulators.database.port;
@@ -946,7 +953,7 @@ STOKER_ALGOLIA_ID="${process.env.ALGOLIA_ID || ""}"
946
953
  STOKER_FB_FUNCTIONS_REGION="${process.env.FB_FUNCTIONS_REGION}"
947
954
  FB_DATABASE="${projectId}-default-rtdb"
948
955
  FB_FIRESTORE_EXPORT_BUCKET="${projectId}-export"`;
949
- if (process.env.SENTRY_DSN) {
956
+ if (process.env.SENTRY_DSN && !options.development) {
950
957
  envContent += `\nSTOKER_SENTRY_DSN="${process.env.SENTRY_DSN}"`;
951
958
  }
952
959
  if (process.env.TWILIO_ACCOUNT_SID && process.env.TWILIO_AUTH_TOKEN && process.env.TWILIO_PHONE_NUMBER) {
@@ -22,6 +22,6 @@ export const getSome = async (options) => {
22
22
  getSomeOptions.userId = options.user;
23
23
  }
24
24
  const result = await getSomeStoker(path, getSomeOptions);
25
- console.log(JSON.stringify(result.docs, null, 2));
25
+ console.log(JSON.stringify(result.records, null, 2));
26
26
  process.exit();
27
27
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stoker-platform/cli",
3
- "version": "0.5.65",
3
+ "version": "0.5.68",
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.4.2",
27
- "@stoker-platform/node-client": "0.5.47",
28
- "@stoker-platform/types": "0.5.30",
29
- "@stoker-platform/utils": "0.5.39",
27
+ "@stoker-platform/node-client": "0.5.48",
28
+ "@stoker-platform/types": "0.5.31",
29
+ "@stoker-platform/utils": "0.5.40",
30
30
  "algoliasearch": "^5.51.0",
31
31
  "commander": "^14.0.0",
32
32
  "cross-spawn": "^7.0.6",