@stoker-platform/node-client 0.2.1

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 (37) hide show
  1. package/dist/bundle.cjs +14 -0
  2. package/dist/bundle.js +11204 -0
  3. package/dist/types/initializeStoker.d.ts +5 -0
  4. package/dist/types/main.d.ts +28 -0
  5. package/dist/types/read/getCollectionRefs.d.ts +3 -0
  6. package/dist/types/read/getDocumentRefs.d.ts +3 -0
  7. package/dist/types/read/getOne.d.ts +23 -0
  8. package/dist/types/read/getSome.d.ts +38 -0
  9. package/dist/types/utils/convertToTimezone.d.ts +7 -0
  10. package/dist/types/utils/deserializeDeleteSentinels.d.ts +2 -0
  11. package/dist/types/utils/deserializeTimestamps.d.ts +3 -0
  12. package/dist/types/utils/fetchSchema.d.ts +3 -0
  13. package/dist/types/utils/getCustomizationFiles.d.ts +2 -0
  14. package/dist/types/utils/getFirestorePathRef.d.ts +2 -0
  15. package/dist/types/utils/getRecordAccess.d.ts +3 -0
  16. package/dist/types/utils/getUser.d.ts +1 -0
  17. package/dist/types/utils/initializeFirebase.d.ts +1 -0
  18. package/dist/types/utils/runChildProcess.d.ts +1 -0
  19. package/dist/types/utils/sendMail.d.ts +5 -0
  20. package/dist/types/utils/sendMessage.d.ts +1 -0
  21. package/dist/types/utils/serializeTimestamps.d.ts +2 -0
  22. package/dist/types/utils/validateCollectionPath.d.ts +2 -0
  23. package/dist/types/write/addRecord.d.ts +20 -0
  24. package/dist/types/write/addUser.d.ts +2 -0
  25. package/dist/types/write/deleteRecord.d.ts +16 -0
  26. package/dist/types/write/deleteUser.d.ts +2 -0
  27. package/dist/types/write/entityRestrictionAccess.d.ts +5 -0
  28. package/dist/types/write/lockRecord.d.ts +3 -0
  29. package/dist/types/write/rollbackUser.d.ts +3 -0
  30. package/dist/types/write/uniqueValidation.d.ts +2 -0
  31. package/dist/types/write/updateRecord.d.ts +21 -0
  32. package/dist/types/write/updateUser.d.ts +3 -0
  33. package/dist/types/write/validateRelations.d.ts +8 -0
  34. package/dist/types/write/validateSoftDelete.d.ts +2 -0
  35. package/dist/types/write/validateSystemFields.d.ts +2 -0
  36. package/dist/types/write/writeLog.d.ts +2 -0
  37. package/package.json +45 -0
@@ -0,0 +1,5 @@
1
+ import { CollectionCustomization, CollectionsSchema, GlobalConfig, NodeUtilities, VersionInfo } from "@stoker-platform/types";
2
+ export declare const initializeStoker: (modeEnv: "development" | "production", configFilePath: string, customizationFilesPath: string, gcp?: boolean) => Promise<NodeUtilities>;
3
+ export declare const getMode: () => "development" | "production", getTimezone: () => string, getGlobalConfigModule: () => GlobalConfig, getCustomizationFile: (collection: string, schema: CollectionsSchema) => CollectionCustomization, getVersionInfo: () => VersionInfo | undefined, getMaintenanceInfo: () => {
4
+ active: boolean;
5
+ } | undefined;
@@ -0,0 +1,28 @@
1
+ export { runChildProcess } from "./utils/runChildProcess.js";
2
+ export { initializeFirebase } from "./utils/initializeFirebase.js";
3
+ export { initializeStoker } from "./initializeStoker.js";
4
+ export { fetchCurrentSchema, fetchLastSchema } from "./utils/fetchSchema.js";
5
+ export { getCollectionRefs } from "./read/getCollectionRefs.js";
6
+ export { getDocumentRefs } from "./read/getDocumentRefs.js";
7
+ export { getOne } from "./read/getOne.js";
8
+ export { getSome } from "./read/getSome.js";
9
+ export { addRecord } from "./write/addRecord.js";
10
+ export { updateRecord } from "./write/updateRecord.js";
11
+ export { deleteRecord } from "./write/deleteRecord.js";
12
+ export { writeLog } from "./write/writeLog.js";
13
+ export { sendMail } from "./utils/sendMail.js";
14
+ export { sendMessage } from "./utils/sendMessage.js";
15
+ export { getFirestorePathRef } from "./utils/getFirestorePathRef.js";
16
+ export { serializeTimestamps } from "./utils/serializeTimestamps.js";
17
+ export { deserializeTimestamps, deserializeTimestampsWithoutUnderscores } from "./utils/deserializeTimestamps.js";
18
+ export { deserializeDeleteSentinels } from "./utils/deserializeDeleteSentinels.js";
19
+ export { getCustomizationFiles } from "./utils/getCustomizationFiles.js";
20
+ export { getUser } from "./utils/getUser.js";
21
+ export { addUser } from "./write/addUser.js";
22
+ export { updateUser } from "./write/updateUser.js";
23
+ export { deleteUser } from "./write/deleteUser.js";
24
+ export { validateSoftDelete } from "./write/validateSoftDelete.js";
25
+ export { validateRelations } from "./write/validateRelations.js";
26
+ export { convertTimestampToTimezone, convertDateToTimezone, keepTimezone, removeTimezone, displayDate, } from "./utils/convertToTimezone.js";
27
+ export { tryPromise, getCachedConfigValue, getSchema as getZodSchema, getInputSchema, isDeleteSentinel, } from "@stoker-platform/utils";
28
+ export type { GetOneOptions } from "./read/getOne.js";
@@ -0,0 +1,3 @@
1
+ import { CollectionsSchema, StokerPermissions } from "@stoker-platform/types";
2
+ import { Query } from "firebase-admin/firestore";
3
+ export declare const getCollectionRefs: (path: string[], schema: CollectionsSchema, userId?: string, permissions?: StokerPermissions) => Query[];
@@ -0,0 +1,3 @@
1
+ import { CollectionsSchema, StokerPermissions } from "@stoker-platform/types";
2
+ import { DocumentReference } from "firebase-admin/firestore";
3
+ export declare const getDocumentRefs: (path: string[], docId: string, schema: CollectionsSchema, permissions?: StokerPermissions) => DocumentReference[];
@@ -0,0 +1,23 @@
1
+ import { CollectionField, StokerCollection, StokerRecord } from "@stoker-platform/types";
2
+ import { Transaction } from "firebase-admin/firestore";
3
+ export interface GetOneOptions {
4
+ user?: string;
5
+ subcollections?: {
6
+ collections?: StokerCollection[];
7
+ depth: number;
8
+ constraints?: [string, string, unknown][];
9
+ limit?: {
10
+ number: number;
11
+ orderByField: string;
12
+ orderByDirection: "asc" | "desc";
13
+ };
14
+ };
15
+ relations?: {
16
+ fields?: (string | CollectionField)[];
17
+ depth: number;
18
+ };
19
+ providedTransaction?: Transaction;
20
+ noComputedFields?: boolean;
21
+ noEmbeddingFields?: boolean;
22
+ }
23
+ export declare const getOne: (path: string[], docId: string, options?: GetOneOptions) => Promise<StokerRecord>;
@@ -0,0 +1,38 @@
1
+ import { CollectionField, StokerCollection, StokerRecord } from "@stoker-platform/types";
2
+ import { DocumentSnapshot, Transaction } from "firebase-admin/firestore";
3
+ export type Cursor = {
4
+ first: Map<number, DocumentSnapshot>;
5
+ last: Map<number, DocumentSnapshot>;
6
+ };
7
+ export interface GetSomeOptions {
8
+ user?: string;
9
+ relations?: {
10
+ fields?: (string | CollectionField)[];
11
+ depth: number;
12
+ };
13
+ subcollections?: {
14
+ collections?: StokerCollection[];
15
+ depth: number;
16
+ constraints?: [string, string, unknown][];
17
+ limit?: {
18
+ number: number;
19
+ orderByField: string;
20
+ orderByDirection: "asc" | "desc";
21
+ };
22
+ };
23
+ pagination?: {
24
+ number: number;
25
+ orderByField?: string;
26
+ orderByDirection?: "asc" | "desc";
27
+ startAfter?: Cursor;
28
+ endBefore?: Cursor;
29
+ };
30
+ transactional?: boolean;
31
+ providedTransaction?: Transaction;
32
+ noEmbeddingFields?: boolean;
33
+ }
34
+ export declare const getSome: (path: string[], constraints?: [string, string, unknown][], options?: GetSomeOptions) => Promise<{
35
+ cursor: Cursor;
36
+ pages: number;
37
+ docs: StokerRecord[];
38
+ }>;
@@ -0,0 +1,7 @@
1
+ import { FieldValue, Timestamp } from "firebase-admin/firestore";
2
+ import { DateTime } from "luxon";
3
+ export declare const convertDateToTimezone: (date: Date) => DateTime<true> | DateTime<false>;
4
+ export declare const convertTimestampToTimezone: (timestamp: Timestamp) => DateTime<true> | DateTime<false>;
5
+ export declare const keepTimezone: (date: Date, timezone: string) => Date;
6
+ export declare const removeTimezone: (date: Date, timezone: string) => Date;
7
+ export declare const displayDate: (timestamp: Timestamp | FieldValue) => string;
@@ -0,0 +1,2 @@
1
+ import { StokerRecord } from "@stoker-platform/types";
2
+ export declare const deserializeDeleteSentinels: (record: Partial<StokerRecord>) => void;
@@ -0,0 +1,3 @@
1
+ import { StokerRecord } from "@stoker-platform/types";
2
+ export declare const deserializeTimestampsWithoutUnderscores: (record: Partial<StokerRecord>) => void;
3
+ export declare const deserializeTimestamps: (record: Partial<StokerRecord>) => void;
@@ -0,0 +1,3 @@
1
+ import type { CollectionsSchema } from "@stoker-platform/types";
2
+ export declare const fetchCurrentSchema: (includeComputedFields?: boolean) => Promise<CollectionsSchema>;
3
+ export declare const fetchLastSchema: () => Promise<CollectionsSchema | undefined>;
@@ -0,0 +1,2 @@
1
+ import { StokerCollection } from "@stoker-platform/types";
2
+ export declare const getCustomizationFiles: (path: string, collections: StokerCollection[]) => Promise<any>;
@@ -0,0 +1,2 @@
1
+ import { Firestore } from "firebase-admin/firestore";
2
+ export declare const getFirestorePathRef: (db: Firestore, path: string[]) => any;
@@ -0,0 +1,3 @@
1
+ import { CollectionSchema, StokerPermissions } from "@stoker-platform/types";
2
+ import { Transaction } from "firebase-admin/firestore";
3
+ export declare const getRecordAccess: (transaction: Transaction, collection: CollectionSchema, id: string, user: string, permissions: StokerPermissions) => Promise<boolean>;
@@ -0,0 +1 @@
1
+ export declare const getUser: (id: string) => Promise<import("firebase-admin/auth").UserRecord>;
@@ -0,0 +1 @@
1
+ export declare const initializeFirebase: () => Promise<import("firebase-admin/app").App>;
@@ -0,0 +1 @@
1
+ export declare const runChildProcess: (command: string, args: string[], cwd?: string, env?: NodeJS.ProcessEnv) => Promise<string>;
@@ -0,0 +1,5 @@
1
+ export declare const sendMail: (to: string | string[], subject: string, text?: string, html?: string, cc?: string | string[], bcc?: string | string[], replyTo?: string, attachments?: {
2
+ filename: string;
3
+ content: Buffer;
4
+ contentType: string;
5
+ }[], from?: string) => Promise<void>;
@@ -0,0 +1 @@
1
+ export declare const sendMessage: (to: string, body: string) => Promise<void>;
@@ -0,0 +1,2 @@
1
+ import { StokerRecord } from "@stoker-platform/types";
2
+ export declare const serializeTimestamps: (record: Partial<StokerRecord>) => void;
@@ -0,0 +1,2 @@
1
+ import { CollectionSchema } from "@stoker-platform/types";
2
+ export declare const validateCollectionPath: (path: string[], collectionSchema: CollectionSchema) => Promise<void>;
@@ -0,0 +1,20 @@
1
+ import { FieldValue } from "firebase-admin/firestore";
2
+ import { StokerRecord, StokerPermissions } from "@stoker-platform/types";
3
+ export declare const addRecord: (path: string[], data: Partial<StokerRecord>, user?: {
4
+ password: string;
5
+ permissions?: StokerPermissions;
6
+ }, userId?: string, options?: {
7
+ noTwoWay?: boolean;
8
+ }, context?: any, id?: string) => Promise<{
9
+ Collection_Path: string[];
10
+ Last_Write_At: import("@firebase/firestore").Timestamp | FieldValue;
11
+ Last_Save_At: import("@firebase/firestore").Timestamp | FieldValue;
12
+ Last_Write_By: string;
13
+ Last_Write_App: string;
14
+ Last_Write_Connection_Status: "Online" | "Offline";
15
+ Last_Write_Version: number;
16
+ Created_At: import("@firebase/firestore").Timestamp | FieldValue;
17
+ Saved_At: import("@firebase/firestore").Timestamp | FieldValue;
18
+ Created_By: string;
19
+ id: any;
20
+ }>;
@@ -0,0 +1,2 @@
1
+ import { GlobalConfig, StokerCollection, StokerPermissions, StokerRecord } from "@stoker-platform/types";
2
+ export declare const addUser: (docId: string, globalConfig: GlobalConfig, collection: StokerCollection, record: StokerRecord, permissions: StokerPermissions, password: string) => Promise<string>;
@@ -0,0 +1,16 @@
1
+ import { FieldValue } from "firebase-admin/firestore";
2
+ export declare const deleteRecord: (path: string[], docId: string, userId?: string, options?: {
3
+ force?: boolean;
4
+ }, context?: any) => Promise<{
5
+ Collection_Path: string[];
6
+ Last_Write_At: import("@firebase/firestore").Timestamp | FieldValue;
7
+ Last_Save_At: import("@firebase/firestore").Timestamp | FieldValue;
8
+ Last_Write_By: string;
9
+ Last_Write_App: string;
10
+ Last_Write_Connection_Status: "Online" | "Offline";
11
+ Last_Write_Version: number;
12
+ Created_At: import("@firebase/firestore").Timestamp | FieldValue;
13
+ Saved_At: import("@firebase/firestore").Timestamp | FieldValue;
14
+ Created_By: string;
15
+ id: string;
16
+ }>;
@@ -0,0 +1,2 @@
1
+ import { StokerRecord } from "@stoker-platform/types";
2
+ export declare const deleteUser: (record: StokerRecord) => Promise<void>;
@@ -0,0 +1,5 @@
1
+ import { CollectionsSchema, StokerPermissions } from "@stoker-platform/types";
2
+ import { Transaction } from "firebase-admin/firestore";
3
+ export declare const entityRestrictionAccess: (transaction: Transaction, userPermissions: StokerPermissions, userId: string, currentUserPermissions: StokerPermissions, schema: CollectionsSchema, originalPermissions?: StokerPermissions, batchSize?: {
4
+ size: number;
5
+ }) => Promise<void>;
@@ -0,0 +1,3 @@
1
+ import { Transaction } from "firebase-admin/firestore";
2
+ export declare const lockRecord: (transaction: Transaction, docId: string, userId: string) => Promise<void>;
3
+ export declare const unlockRecord: (docId: string, userId: string) => Promise<void>;
@@ -0,0 +1,3 @@
1
+ import { UserRecord } from "firebase-admin/auth";
2
+ import { StokerPermissions } from "@stoker-platform/types";
3
+ export declare const rollbackUser: (id: string, originalUser: UserRecord, originalPermissions: StokerPermissions, message: string) => Promise<void>;
@@ -0,0 +1,2 @@
1
+ import { CollectionSchema, CollectionsSchema, StokerPermissions, StokerRecord } from "@stoker-platform/types";
2
+ export declare const uniqueValidation: (operation: "create" | "update", docId: string, data: StokerRecord, collectionSchema: CollectionSchema, schema: CollectionsSchema, user?: string, permissions?: StokerPermissions) => Promise<void>;
@@ -0,0 +1,21 @@
1
+ import { FieldValue } from "firebase-admin/firestore";
2
+ import { StokerRecord, StokerPermissions } from "@stoker-platform/types";
3
+ export declare const updateRecord: (path: string[], docId: string, data: Partial<StokerRecord>, user?: {
4
+ operation: "create" | "update" | "delete";
5
+ password?: string;
6
+ permissions?: StokerPermissions;
7
+ }, userId?: string, options?: {
8
+ noTwoWay?: boolean;
9
+ }, context?: any) => Promise<{
10
+ Collection_Path: string[];
11
+ Last_Write_At: import("@firebase/firestore").Timestamp | FieldValue;
12
+ Last_Save_At: import("@firebase/firestore").Timestamp | FieldValue;
13
+ Last_Write_By: string;
14
+ Last_Write_App: string;
15
+ Last_Write_Connection_Status: "Online" | "Offline";
16
+ Last_Write_Version: number;
17
+ Created_At: import("@firebase/firestore").Timestamp | FieldValue;
18
+ Saved_At: import("@firebase/firestore").Timestamp | FieldValue;
19
+ Created_By: string;
20
+ id: string;
21
+ }>;
@@ -0,0 +1,3 @@
1
+ import { GlobalConfig, StokerCollection, StokerPermissions, StokerRecord } from "@stoker-platform/types";
2
+ import { UserRecord } from "firebase-admin/auth";
3
+ export declare const updateUser: (operation: "create" | "update" | "delete", docId: string, globalConfig: GlobalConfig, collection: StokerCollection, record: StokerRecord, originalRecord: StokerRecord, originalUser?: UserRecord, permissions?: StokerPermissions, originalPermissions?: StokerPermissions, password?: string) => Promise<string | undefined>;
@@ -0,0 +1,8 @@
1
+ import { CollectionField, CollectionSchema, CollectionsSchema, StokerPermissions, StokerRecord } from "@stoker-platform/types";
2
+ import { Transaction } from "firebase-admin/firestore";
3
+ export declare const validateRelationHierarchy: (collection: CollectionSchema, field: CollectionField, record: StokerRecord, transaction: Transaction, batchSize: {
4
+ size: number;
5
+ }, isRelationCheck?: boolean) => Promise<void>;
6
+ export declare const validateRelations: (operation: "Create" | "Update", docId: string, record: StokerRecord, partial: Partial<StokerRecord>, collectionSchema: CollectionSchema, schema: CollectionsSchema, transaction: Transaction, batchSize: {
7
+ size: number;
8
+ }, userId?: string, permissions?: StokerPermissions, originalRecord?: StokerRecord) => Promise<Map<string, string[]>>;
@@ -0,0 +1,2 @@
1
+ import { CollectionSchema, StokerRecord } from "@stoker-platform/types";
2
+ export declare const validateSoftDelete: (operation: "create" | "update", collection: CollectionSchema, record: StokerRecord, originalRecord?: StokerRecord) => void;
@@ -0,0 +1,2 @@
1
+ import { StokerRecord } from "@stoker-platform/types";
2
+ export declare const validateSystemFields: (operation: "create" | "update", data: Partial<StokerRecord>, originalSystemFields: Partial<StokerRecord>) => void;
@@ -0,0 +1,2 @@
1
+ import { CollectionSchema, StokerRecord } from "@stoker-platform/types";
2
+ export declare const writeLog: (operation: "create" | "update" | "delete", status: "started" | "written" | "success" | "failed", data: StokerRecord, path: string[], docId: string, collectionSchema: CollectionSchema, error?: unknown, originalRecord?: StokerRecord) => Promise<void>;
package/package.json ADDED
@@ -0,0 +1,45 @@
1
+ {
2
+ "name": "@stoker-platform/node-client",
3
+ "publishConfig": {
4
+ "access": "restricted"
5
+ },
6
+ "version": "0.2.1",
7
+ "type": "module",
8
+ "license": "UNLICENSED",
9
+ "files": [
10
+ "dist"
11
+ ],
12
+ "main": "./dist/bundle.cjs",
13
+ "module": "./dist/bundle.js",
14
+ "exports": {
15
+ ".": {
16
+ "import": "./dist/bundle.js",
17
+ "require": "./dist/bundle.cjs"
18
+ }
19
+ },
20
+ "types": "./dist/types/main.d.ts",
21
+ "scripts": {
22
+ "dev": "vite build --watch",
23
+ "lint": "tsc",
24
+ "build": "vite build"
25
+ },
26
+ "dependencies": {
27
+ "@google-cloud/storage": "^7.18.0",
28
+ "@stoker-platform/types": "0.2.1",
29
+ "@stoker-platform/utils": "0.2.1",
30
+ "@types/luxon": "^3.7.1",
31
+ "firebase-admin": "^13.6.0",
32
+ "lodash": "^4.17.21",
33
+ "luxon": "^3.7.2"
34
+ },
35
+ "devDependencies": {
36
+ "@rollup/plugin-typescript": "^12.3.0",
37
+ "eslint-config-custom": "*",
38
+ "tsconfig": "*",
39
+ "vite-plugin-eslint": "^1.8.1"
40
+ },
41
+ "engines": {
42
+ "node": "22",
43
+ "npm": "11"
44
+ }
45
+ }