@wenex/sdk 1.0.56 → 1.1.0

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.
@@ -1,24 +1,24 @@
1
- export declare enum Collection {
2
- Grants = "grants",
3
- Configs = "configs",
4
- Settings = "settings",
5
- Apps = "apps",
6
- Clients = "clients",
7
- Sagas = "sagas",
8
- SagaStages = "saga-stages",
9
- Wallets = "wallets",
10
- Accounts = "accounts",
11
- Invoices = "invoices",
12
- Currencies = "currencies",
13
- Transactions = "transactions",
14
- Workflows = "workflows",
15
- Users = "users",
16
- Profiles = "profiles",
17
- Sessions = "sessions",
18
- Files = "files",
19
- Stats = "stats",
20
- Smss = "smss",
21
- Emails = "emails",
22
- Pushes = "pushes",
23
- PusHistories = "push-histories"
24
- }
1
+ /**
2
+ * Note: <keep all update>
3
+ * - Replace all "_" in app service names with "-"
4
+ * - Enums of Collection and Database exists at "./enums"
5
+ */
6
+ type AUTH = 'GRANTS';
7
+ type DOMAIN = 'APPS' | 'CLIENTS';
8
+ type CONTEXT = 'CONFIGS' | 'SETTINGS';
9
+ type IDENTITY = 'USERS' | 'SESSIONS' | 'PROFILES';
10
+ type ESSENTIAL = 'SAGAS' | 'SAGA-STAGES';
11
+ type FINANCIAL = 'WALLETS' | 'ACCOUNTS' | 'INVOICES' | 'CURRENCIES' | 'TRANSACTIONS';
12
+ type GENERAL = 'NOTICES' | 'ARTIFACTS' | 'WORKFLOWS' | 'ACTIVITIES';
13
+ type SPECIAL = 'STATS' | 'FILES';
14
+ type TOUCH = 'EMAILS' | 'SMSS' | 'PUSHES' | 'PUSH-HISTORIES';
15
+ type CONTENT = 'NOTES' | 'POSTS' | 'TICKETS';
16
+ type LOGISTIC = 'CARGOES' | 'DRIVERS' | 'TRAVELS' | 'VEHICLES' | 'LOCATIONS';
17
+ type COLL = AUTH | DOMAIN | CONTEXT | IDENTITY | ESSENTIAL | FINANCIAL | GENERAL | SPECIAL | TOUCH | CONTENT | LOGISTIC;
18
+ type DB = 'AUTH' | 'DOMAIN' | 'CONTEXT' | 'IDENTITY' | 'ESSENTIAL' | 'FINANCIAL' | 'GENERAL' | 'SPECIAL' | 'TOUCH' | 'CONTENT' | 'LOGISTIC';
19
+ export type Database = Lowercase<DB>;
20
+ export type Collection = Lowercase<`AUTH/${AUTH}`> | Lowercase<`DOMAIN/${DOMAIN}`> | Lowercase<`CONTEXT/${CONTEXT}`> | Lowercase<`IDENTITY/${IDENTITY}`> | Lowercase<`ESSENTIAL/${ESSENTIAL}`> | Lowercase<`FINANCIAL/${FINANCIAL}`> | Lowercase<`GENERAL/${GENERAL}`> | Lowercase<`SPECIAL/${SPECIAL}`> | Lowercase<`TOUCH/${TOUCH}`> | Lowercase<`CONTENT/${CONTENT}`> | Lowercase<`LOGISTIC/${LOGISTIC}`>;
21
+ export type Coll = Lowercase<COLL>;
22
+ export declare const COLLECTION: (coll: Coll, db?: Database) => Collection;
23
+ export declare const COLL: (collection: Collection) => [Coll, Database];
24
+ export {};
@@ -1,38 +1,30 @@
1
1
  "use strict";
2
+ /**
3
+ * Note: <keep all update>
4
+ * - Replace all "_" in app service names with "-"
5
+ * - Enums of Collection and Database exists at "./enums"
6
+ */
2
7
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Collection = void 0;
4
- var Collection;
5
- (function (Collection) {
6
- // Auth
7
- Collection["Grants"] = "grants";
8
- // Context
9
- Collection["Configs"] = "configs";
10
- Collection["Settings"] = "settings";
11
- // Domain
12
- Collection["Apps"] = "apps";
13
- Collection["Clients"] = "clients";
14
- // Essential
15
- Collection["Sagas"] = "sagas";
16
- Collection["SagaStages"] = "saga-stages";
17
- // Financial
18
- Collection["Wallets"] = "wallets";
19
- Collection["Accounts"] = "accounts";
20
- Collection["Invoices"] = "invoices";
21
- Collection["Currencies"] = "currencies";
22
- Collection["Transactions"] = "transactions";
23
- // General
24
- Collection["Workflows"] = "workflows";
25
- // Identity
26
- Collection["Users"] = "users";
27
- Collection["Profiles"] = "profiles";
28
- Collection["Sessions"] = "sessions";
29
- // Special
30
- Collection["Files"] = "files";
31
- Collection["Stats"] = "stats";
32
- // Touch
33
- Collection["Smss"] = "smss";
34
- Collection["Emails"] = "emails";
35
- Collection["Pushes"] = "pushes";
36
- Collection["PusHistories"] = "push-histories";
37
- })(Collection || (exports.Collection = Collection = {}));
8
+ exports.COLL = exports.COLLECTION = void 0;
9
+ const collection_enum_1 = require("./enums/collection.enum");
10
+ const COLLECTION = (coll, db) => {
11
+ if (!db && !process.env['PROTOTYPING_APP'])
12
+ throw Error(`unknown ?.${coll}`);
13
+ const name = db || process.env['PROTOTYPING_APP']?.toLowerCase();
14
+ const collection = `${name.toLowerCase()}/${coll}`;
15
+ if (!Object.values(collection_enum_1.Collection).includes(collection)) {
16
+ throw Error('unknown collection');
17
+ }
18
+ else
19
+ return collection;
20
+ };
21
+ exports.COLLECTION = COLLECTION;
22
+ const COLL = (collection) => {
23
+ if (!Object.values(collection_enum_1.Collection).includes(collection)) {
24
+ throw Error('unknown collection');
25
+ }
26
+ else
27
+ return collection.split('/').reverse();
28
+ };
29
+ exports.COLL = COLL;
38
30
  //# sourceMappingURL=collection.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"collection.js","sourceRoot":"","sources":["../../src/common/core/collection.ts"],"names":[],"mappings":";;;AAAA,IAAY,UAwCX;AAxCD,WAAY,UAAU;IACpB,OAAO;IACP,+BAAiB,CAAA;IAEjB,UAAU;IACV,iCAAmB,CAAA;IACnB,mCAAqB,CAAA;IAErB,SAAS;IACT,2BAAa,CAAA;IACb,iCAAmB,CAAA;IAEnB,YAAY;IACZ,6BAAe,CAAA;IACf,wCAA0B,CAAA;IAE1B,YAAY;IACZ,iCAAmB,CAAA;IACnB,mCAAqB,CAAA;IACrB,mCAAqB,CAAA;IACrB,uCAAyB,CAAA;IACzB,2CAA6B,CAAA;IAE7B,UAAU;IACV,qCAAuB,CAAA;IAEvB,WAAW;IACX,6BAAe,CAAA;IACf,mCAAqB,CAA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"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const collection_1 = require("./collection");
4
+ describe('libs/common/src/core/collection.ts', () => {
5
+ it('COLL', () => {
6
+ expect((0, collection_1.COLL)('auth/grants')).toStrictEqual(['grants', 'auth']);
7
+ });
8
+ it('COLLECTION', () => {
9
+ expect((0, collection_1.COLLECTION)('accounts', 'financial')).toBe('financial/accounts');
10
+ expect(() => (0, collection_1.COLLECTION)('accounts')).toThrow('unknown ?.accounts');
11
+ process.env['PROTOTYPING_APP'] = 'FINANCIAL';
12
+ expect((0, collection_1.COLLECTION)('accounts')).toBe('financial/accounts');
13
+ });
14
+ });
15
+ //# sourceMappingURL=collection.spec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"collection.spec.js","sourceRoot":"","sources":["../../src/common/core/collection.spec.ts"],"names":[],"mappings":";;AAAA,6CAAgD;AAEhD,QAAQ,CAAC,oCAAoC,EAAE,GAAG,EAAE;IAClD,EAAE,CAAC,MAAM,EAAE,GAAG,EAAE;QACd,MAAM,CAAC,IAAA,iBAAI,EAAC,aAAa,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC,CAAC;IAChE,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,YAAY,EAAE,GAAG,EAAE;QACpB,MAAM,CAAC,IAAA,uBAAU,EAAC,UAAU,EAAE,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAC;QACvE,MAAM,CAAC,GAAG,EAAE,CAAC,IAAA,uBAAU,EAAC,UAAU,CAAC,CAAC,CAAC,OAAO,CAAC,oBAAoB,CAAC,CAAC;QAEnE,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC,GAAG,WAAW,CAAC;QAC7C,MAAM,CAAC,IAAA,uBAAU,EAAC,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAC;IAC5D,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -0,0 +1,38 @@
1
+ /**
2
+ * Note: Base on Collection type at "../collection.ts"
3
+ */
4
+ export declare enum Collection {
5
+ AuthGrants = "auth/grants",
6
+ DomainApps = "domain/apps",
7
+ DomainClients = "domain/clients",
8
+ ContextConfigs = "context/configs",
9
+ ContextSettings = "context/settings",
10
+ IdentityUsers = "identity/users",
11
+ IdentitySessions = "identity/sessions",
12
+ IdentityProfiles = "identity/profiles",
13
+ EssentialSagas = "essential/sagas",
14
+ EssentialSagaStages = "essential/saga-stages",
15
+ FinancialWallets = "financial/wallets",
16
+ FinancialAccounts = "financial/accounts",
17
+ FinancialInvoices = "financial/invoices",
18
+ FinancialCurrencies = "financial/currencies",
19
+ FinancialTransactions = "financial/transactions",
20
+ GeneralNotices = "general/notices",
21
+ GeneralArtifacts = "general/artifacts",
22
+ GeneralWorkflows = "general/workflows",
23
+ GeneralActivities = "general/activities",
24
+ SpecialStats = "special/stats",
25
+ SpecialFiles = "special/files",
26
+ TouchEmails = "touch/emails",
27
+ TouchSmss = "touch/smss",
28
+ TouchPushes = "touch/pushes",
29
+ TouchPushHistories = "touch/push-histories",
30
+ ContentNotes = "content/notes",
31
+ ContentPosts = "content/posts",
32
+ ContentTickets = "content/tickets",
33
+ LogisticCargoes = "logistic/cargoes",
34
+ LogisticDrivers = "logistic/drivers",
35
+ LogisticTravels = "logistic/travels",
36
+ LogisticVehicles = "logistic/vehicles",
37
+ LogisticLocations = "logistic/locations"
38
+ }
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Collection = void 0;
4
+ /**
5
+ * Note: Base on Collection type at "../collection.ts"
6
+ */
7
+ var Collection;
8
+ (function (Collection) {
9
+ // Auth
10
+ Collection["AuthGrants"] = "auth/grants";
11
+ // Domain
12
+ Collection["DomainApps"] = "domain/apps";
13
+ Collection["DomainClients"] = "domain/clients";
14
+ // Context
15
+ Collection["ContextConfigs"] = "context/configs";
16
+ Collection["ContextSettings"] = "context/settings";
17
+ // Identity
18
+ Collection["IdentityUsers"] = "identity/users";
19
+ Collection["IdentitySessions"] = "identity/sessions";
20
+ Collection["IdentityProfiles"] = "identity/profiles";
21
+ // Essential
22
+ Collection["EssentialSagas"] = "essential/sagas";
23
+ Collection["EssentialSagaStages"] = "essential/saga-stages";
24
+ // Financial
25
+ Collection["FinancialWallets"] = "financial/wallets";
26
+ Collection["FinancialAccounts"] = "financial/accounts";
27
+ Collection["FinancialInvoices"] = "financial/invoices";
28
+ Collection["FinancialCurrencies"] = "financial/currencies";
29
+ Collection["FinancialTransactions"] = "financial/transactions";
30
+ // General
31
+ Collection["GeneralNotices"] = "general/notices";
32
+ Collection["GeneralArtifacts"] = "general/artifacts";
33
+ Collection["GeneralWorkflows"] = "general/workflows";
34
+ Collection["GeneralActivities"] = "general/activities";
35
+ // Special
36
+ Collection["SpecialStats"] = "special/stats";
37
+ Collection["SpecialFiles"] = "special/files";
38
+ // Touch
39
+ Collection["TouchEmails"] = "touch/emails";
40
+ Collection["TouchSmss"] = "touch/smss";
41
+ Collection["TouchPushes"] = "touch/pushes";
42
+ Collection["TouchPushHistories"] = "touch/push-histories";
43
+ // Content
44
+ Collection["ContentNotes"] = "content/notes";
45
+ Collection["ContentPosts"] = "content/posts";
46
+ Collection["ContentTickets"] = "content/tickets";
47
+ // Logistic
48
+ Collection["LogisticCargoes"] = "logistic/cargoes";
49
+ Collection["LogisticDrivers"] = "logistic/drivers";
50
+ Collection["LogisticTravels"] = "logistic/travels";
51
+ Collection["LogisticVehicles"] = "logistic/vehicles";
52
+ Collection["LogisticLocations"] = "logistic/locations";
53
+ })(Collection || (exports.Collection = Collection = {}));
54
+ //# sourceMappingURL=collection.enum.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"collection.enum.js","sourceRoot":"","sources":["../../../src/common/core/enums/collection.enum.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACH,IAAY,UAuDX;AAvDD,WAAY,UAAU;IACpB,OAAO;IACP,wCAA0B,CAAA;IAE1B,SAAS;IACT,wCAA0B,CAAA;IAC1B,8CAAgC,CAAA;IAEhC,UAAU;IACV,gDAAkC,CAAA;IAClC,kDAAoC,CAAA;IAEpC,WAAW;IACX,8CAAgC,CAAA;IAChC,oDAAsC,CAAA;IACtC,oDAAsC,CAAA;IAEtC,YAAY;IACZ,gDAAkC,CAAA;IAClC,2DAA6C,CAAA;IAE7C,YAAY;IACZ,oDAAsC,CAAA;IACtC,sDAAwC,CAAA;IACxC,sDAAwC,CAAA;IACxC,0DAA4C,CAAA;IAC5C,8DAAgD,CAAA;IAEhD,UAAU;IACV,gDAAkC,CAAA;IAClC,oDAAsC,CAAA;IACtC,oDAAsC,CAAA;IACtC,sDAAwC,CAAA;IAExC,UAAU;IACV,4CAA8B,CAAA;IAC9B,4CAA8B,CAAA;IAE9B,QAAQ;IACR,0CAA4B,CAAA;IAC5B,sCAAwB,CAAA;IACxB,0CAA4B,CAAA;IAC5B,yDAA2C,CAAA;IAE3C,UAAU;IACV,4CAA8B,CAAA;IAC9B,4CAA8B,CAAA;IAC9B,gDAAkC,CAAA;IAElC,WAAW;IACX,kDAAoC,CAAA;IACpC,kDAAoC,CAAA;IACpC,kDAAoC,CAAA;IACpC,oDAAsC,CAAA;IACtC,sDAAwC,CAAA;AAC1C,CAAC,EAvDW,UAAU,0BAAV,UAAU,QAuDrB"}
@@ -1,3 +1,4 @@
1
+ export * from './collection.enum';
1
2
  export * from './gender.enum';
2
3
  export * from './grant-type.enum';
3
4
  export * from './state.enum';
@@ -14,6 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./collection.enum"), exports);
17
18
  __exportStar(require("./gender.enum"), exports);
18
19
  __exportStar(require("./grant-type.enum"), exports);
19
20
  __exportStar(require("./state.enum"), exports);
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/common/core/enums/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,gDAA8B;AAC9B,oDAAkC;AAClC,+CAA6B;AAC7B,gDAA8B;AAC9B,oDAAkC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/common/core/enums/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,oDAAkC;AAClC,gDAA8B;AAC9B,oDAAkC;AAClC,+CAA6B;AAC7B,gDAA8B;AAC9B,oDAAkC"}
@@ -5,10 +5,10 @@ export interface Saga<Properties extends object = object> extends Core<Propertie
5
5
  ttl: number;
6
6
  job: string;
7
7
  state: SagaState;
8
- identity: string;
8
+ session: string;
9
9
  aborted_at?: Date;
10
10
  committed_at?: Date;
11
11
  }
12
12
  export type SagaDoc<Properties extends object = object> = Saga<Properties> & Document;
13
13
  export type SagaDto<Properties extends object = object> = Dto<Saga<Properties>>;
14
- export type SagaStartDto<Properties extends object = object> = Dto<Saga<Properties>, 'job' | 'state' | 'identity'>;
14
+ export type SagaStartDto<Properties extends object = object> = Dto<Saga<Properties>, 'job' | 'state' | 'session'>;
@@ -1,17 +1,16 @@
1
1
  import type { Document } from 'mongoose';
2
- import { Collection } from '../../../../core';
2
+ import { Collection } from '../../../../core/enums';
3
3
  import { SagaStageReq } from '../../../../types/essential';
4
4
  import { SagaStageAction } from '../../../../enums/essential';
5
5
  import { Core, Dto, Metadata, Serializer } from '../../../../core/interfaces';
6
6
  export interface SagaStage<T extends Core = Core, D extends Dto<Core> = Dto<Core>, Properties extends object = object> extends Core<Properties> {
7
7
  saga: string;
8
- db: string;
9
- coll: Collection;
10
8
  action: SagaStageAction;
11
9
  req: SagaStageReq<T, D>;
12
10
  res: Serializer<T>[] | Serializer<T> | number | null;
11
+ collection: Collection;
13
12
  meta?: Metadata;
14
13
  }
15
14
  export type SagaStageDoc<T extends Core = Core, D extends Dto<Core> = Dto<Core>, Properties extends object = object> = SagaStage<T, D, Properties> & Document;
16
15
  export type SagaStageDto<T extends Core = Core, D extends Dto<Core> = Dto<Core>, Properties extends object = object> = Dto<SagaStage<T, D, Properties>>;
17
- export type SagaStageAddDto<T extends Core = Core, D extends Dto<Core> = Dto<Core>, Properties extends object = object> = Dto<SagaStage<T, D, Properties>, 'db' | 'res'>;
16
+ export type SagaStageAddDto<T extends Core = Core, D extends Dto<Core> = Dto<Core>, Properties extends object = object> = Dto<SagaStage<T, D, Properties>, 'res'>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wenex/sdk",
3
- "version": "1.0.56",
3
+ "version": "1.1.0",
4
4
  "description": "Wenex SDK",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",