@nx-ddd/notion 19.0.0-preview.3 → 19.0.0-preview.30

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 (43) hide show
  1. package/fesm2022/nx-ddd-notion.mjs +525 -0
  2. package/fesm2022/nx-ddd-notion.mjs.map +1 -0
  3. package/index.d.ts +1 -0
  4. package/notion/notion.service.impl.d.ts +5 -0
  5. package/package.json +18 -12
  6. package/repository/repository.d.ts +17 -5
  7. package/README.md +0 -11
  8. package/_testing/entity.d.ts +0 -20
  9. package/_testing/entity.js +0 -44
  10. package/_testing/entity.js.map +0 -1
  11. package/_testing/index.d.ts +0 -1
  12. package/_testing/index.js +0 -5
  13. package/_testing/index.js.map +0 -1
  14. package/converter/converter.js +0 -37
  15. package/converter/converter.js.map +0 -1
  16. package/converter/index.js +0 -5
  17. package/converter/index.js.map +0 -1
  18. package/decorators/decorators.js +0 -58
  19. package/decorators/decorators.js.map +0 -1
  20. package/decorators/index.js +0 -5
  21. package/decorators/index.js.map +0 -1
  22. package/index.js +0 -10
  23. package/index.js.map +0 -1
  24. package/notion/index.js +0 -5
  25. package/notion/index.js.map +0 -1
  26. package/notion/notion.service.impl.js +0 -142
  27. package/notion/notion.service.impl.js.map +0 -1
  28. package/notion/notion.service.js +0 -12
  29. package/notion/notion.service.js.map +0 -1
  30. package/query/index.js +0 -5
  31. package/query/index.js.map +0 -1
  32. package/query/query.js +0 -122
  33. package/query/query.js.map +0 -1
  34. package/query-builder/index.js +0 -5
  35. package/query-builder/index.js.map +0 -1
  36. package/query-builder/query-builder.js +0 -30
  37. package/query-builder/query-builder.js.map +0 -1
  38. package/repository/index.js +0 -5
  39. package/repository/index.js.map +0 -1
  40. package/repository/repository.js +0 -112
  41. package/repository/repository.js.map +0 -1
  42. package/utils.js +0 -184
  43. package/utils.js.map +0 -1
package/package.json CHANGED
@@ -1,23 +1,29 @@
1
1
  {
2
2
  "name": "@nx-ddd/notion",
3
- "version": "19.0.0-preview.3",
4
- "main": "./index.js",
5
- "types": "./index.d.ts",
6
- "homepage": "https://github.com/xx-machina/plaform/tree/main/packages/@nx-ddd/notion",
7
- "repository": {
8
- "type": "git",
9
- "url": "https://github.com/xx-machina/plaform.git"
10
- },
3
+ "version": "19.0.0-preview.30",
4
+ "license": "MIT",
11
5
  "peerDependencies": {
12
6
  "@notionhq/client": "^2.2.2",
13
- "@nx-ddd/common": "19.0.0-preview.3",
7
+ "@nx-ddd/common": "19.0.0-preview.30",
14
8
  "dayjs": "1.11.13",
15
9
  "lodash-es": "^4.17.15",
16
- "tslib": "^2.3.0",
17
10
  "@angular/core": "19.1.4",
18
11
  "node-localstorage": "^3.0.5",
19
12
  "crypto-js": "4.2.0"
20
13
  },
21
- "dependencies": {},
22
- "type": "commonjs"
14
+ "dependencies": {
15
+ "tslib": "^2.3.0"
16
+ },
17
+ "module": "fesm2022/nx-ddd-notion.mjs",
18
+ "typings": "index.d.ts",
19
+ "exports": {
20
+ "./package.json": {
21
+ "default": "./package.json"
22
+ },
23
+ ".": {
24
+ "types": "./index.d.ts",
25
+ "default": "./fesm2022/nx-ddd-notion.mjs"
26
+ }
27
+ },
28
+ "sideEffects": false
23
29
  }
@@ -1,10 +1,12 @@
1
1
  import { Client } from '@notionhq/client';
2
- import { Entity } from '@nx-ddd/common/domain/models';
3
- import { Repository } from '@nx-ddd/common/domain/repository';
2
+ import { Entity } from '@nx-ddd/common/domain';
3
+ import { Repository } from '@nx-ddd/common/domain';
4
4
  import { InjectionToken } from '@angular/core';
5
5
  import { NotionConverter } from '../converter';
6
6
  import { NotionBaseQuery } from '../query';
7
7
  import { NotionQueryBuilder } from '../query-builder';
8
+ import { Observable } from 'rxjs';
9
+ import * as i0 from "@angular/core";
8
10
  export declare const NOTION_ACCESS_TOKEN: InjectionToken<string>;
9
11
  export declare const NOTION_DATABASE_ID: InjectionToken<unknown>;
10
12
  export declare function provideNotionConfig(config: {
@@ -14,16 +16,15 @@ export declare function provideNotionConfig(config: {
14
16
  useValue: string;
15
17
  };
16
18
  export declare abstract class NotionRepository<E extends Entity> extends Repository<E> {
17
- protected token: string;
18
19
  protected abstract databaseId: string;
19
20
  protected abstract converter: NotionConverter<E>;
21
+ protected token: string;
20
22
  protected client: Client;
21
23
  protected queryBuilder: NotionQueryBuilder;
22
24
  protected get parent(): {
23
25
  type: 'database_id';
24
26
  database_id: string;
25
27
  };
26
- constructor(token: string);
27
28
  query(filterQuery?: NotionBaseQuery, sortQuery?: NotionBaseQuery, startCursor?: string, pageSize?: number): Promise<{
28
29
  results: E[];
29
30
  nextCursor: string;
@@ -37,12 +38,23 @@ export declare abstract class NotionRepository<E extends Entity> extends Reposit
37
38
  list({ batchSize, }?: {
38
39
  batchSize?: number;
39
40
  }): Promise<E[]>;
41
+ listChanges(): Observable<E[]>;
40
42
  get({ id }: {
41
43
  id: string;
42
44
  }): Promise<E>;
43
- create(entity: Partial<E>): Promise<E>;
45
+ create(entity: Omit<E, 'id' | 'createdAt' | 'updatedAt'> & Partial<Pick<E, 'id'>>): Promise<E>;
46
+ createMany(data: Omit<E, 'id' | 'createdAt' | 'updatedAt'>[]): Promise<E[]>;
44
47
  update(entity: Partial<E>): Promise<void>;
48
+ save(data: Partial<E>): Promise<boolean | [E, boolean]>;
49
+ saveMany(entities: E[]): Promise<void>;
50
+ updateMany(data: Partial<E>[]): Promise<void>;
45
51
  delete({ id }: {
46
52
  id: string;
47
53
  }): Promise<void>;
54
+ deleteMany(params: {
55
+ id: string;
56
+ }[]): Promise<number>;
57
+ deleteAll(): Promise<void>;
58
+ static ɵfac: i0.ɵɵFactoryDeclaration<NotionRepository<any>, never>;
59
+ static ɵprov: i0.ɵɵInjectableDeclaration<NotionRepository<any>>;
48
60
  }
package/README.md DELETED
@@ -1,11 +0,0 @@
1
- # notion
2
-
3
- This library was generated with [Nx](https://nx.dev).
4
-
5
- ## Running unit tests
6
-
7
- Run `nx test notion` to execute the unit tests via [Jest](https://jestjs.io).
8
-
9
- ## Running lint
10
-
11
- Run `nx lint notion` to execute the lint via [ESLint](https://eslint.org/).
@@ -1,20 +0,0 @@
1
- import { NotionConverter } from '../converter';
2
- export declare class Entity {
3
- title: string;
4
- status: string;
5
- firstSelectionIds: string[];
6
- discordFirstSelectionMessage: string;
7
- discordSecondSelectionMessage: string;
8
- discordChannelId: string;
9
- static from(obj: Partial<Entity>): Entity & {
10
- title?: string;
11
- status?: string;
12
- firstSelectionIds?: string[];
13
- discordFirstSelectionMessage?: string;
14
- discordSecondSelectionMessage?: string;
15
- discordChannelId?: string;
16
- };
17
- }
18
- export declare class EntityConverter extends NotionConverter<Entity> {
19
- protected Entity: typeof Entity;
20
- }
@@ -1,44 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.EntityConverter = exports.Entity = void 0;
4
- const tslib_1 = require("tslib");
5
- const converter_1 = require("../converter");
6
- const decorators_1 = require("../decorators");
7
- class Entity {
8
- static from(obj) {
9
- return Object.assign(new Entity(), Object.assign({}, obj));
10
- }
11
- }
12
- exports.Entity = Entity;
13
- tslib_1.__decorate([
14
- (0, decorators_1.Title)('タイトル'),
15
- tslib_1.__metadata("design:type", String)
16
- ], Entity.prototype, "title", void 0);
17
- tslib_1.__decorate([
18
- (0, decorators_1.Status)('ステータス'),
19
- tslib_1.__metadata("design:type", String)
20
- ], Entity.prototype, "status", void 0);
21
- tslib_1.__decorate([
22
- (0, decorators_1.Relation)('一次選考'),
23
- tslib_1.__metadata("design:type", Array)
24
- ], Entity.prototype, "firstSelectionIds", void 0);
25
- tslib_1.__decorate([
26
- (0, decorators_1.Formula)('一次選考開始文(Discord)'),
27
- tslib_1.__metadata("design:type", String)
28
- ], Entity.prototype, "discordFirstSelectionMessage", void 0);
29
- tslib_1.__decorate([
30
- (0, decorators_1.Formula)('二次選考開始文(Discord)'),
31
- tslib_1.__metadata("design:type", String)
32
- ], Entity.prototype, "discordSecondSelectionMessage", void 0);
33
- tslib_1.__decorate([
34
- (0, decorators_1.RichText)('discordChannelId'),
35
- tslib_1.__metadata("design:type", String)
36
- ], Entity.prototype, "discordChannelId", void 0);
37
- class EntityConverter extends converter_1.NotionConverter {
38
- constructor() {
39
- super(...arguments);
40
- this.Entity = Entity;
41
- }
42
- }
43
- exports.EntityConverter = EntityConverter;
44
- //# sourceMappingURL=entity.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"entity.js","sourceRoot":"","sources":["../../../../../packages/@nx-ddd/notion/src/lib/_testing/entity.ts"],"names":[],"mappings":";;;;AAAA,4CAA+C;AAC/C,8CAA2E;AAE3E,MAAa,MAAM;IAmBjB,MAAM,CAAC,IAAI,CAAC,GAAoB;QAC9B,OAAO,MAAM,CAAC,MAAM,CAAC,IAAI,MAAM,EAAE,oBAAM,GAAG,EAAE,CAAC;IAC/C,CAAC;CACF;AAtBD,wBAsBC;AApBC;IADC,IAAA,kBAAK,EAAC,MAAM,CAAC;;qCACA;AAGd;IADC,IAAA,mBAAM,EAAC,OAAO,CAAC;;sCACD;AAGf;IADC,IAAA,qBAAQ,EAAC,MAAM,CAAC;;iDACW;AAG5B;IADC,IAAA,oBAAO,EAAC,kBAAkB,CAAC;;4DACS;AAGrC;IADC,IAAA,oBAAO,EAAC,kBAAkB,CAAC;;6DACU;AAGtC;IADC,IAAA,qBAAQ,EAAC,kBAAkB,CAAC;;gDACJ;AAO3B,MAAa,eAAgB,SAAQ,2BAAuB;IAA5D;;QACY,WAAM,GAAG,MAAM,CAAC;IAC5B,CAAC;CAAA;AAFD,0CAEC"}
@@ -1 +0,0 @@
1
- export * from './entity';
package/_testing/index.js DELETED
@@ -1,5 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
- tslib_1.__exportStar(require("./entity"), exports);
5
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../packages/@nx-ddd/notion/src/lib/_testing/index.ts"],"names":[],"mappings":";;;AAAA,mDAAyB"}
@@ -1,37 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.NotionConverter = void 0;
4
- exports.createConverter = createConverter;
5
- const utils_1 = require("../utils");
6
- const decorators_1 = require("../decorators");
7
- const lodash_es_1 = require("lodash-es");
8
- class NotionConverter {
9
- fromNotion(page) {
10
- var _a;
11
- const annotations = (_a = this.Entity[decorators_1.NOTION_ANNOTATIONS]) !== null && _a !== void 0 ? _a : [];
12
- const obj = annotations.reduce((obj, annotation) => {
13
- const value = page['properties'][annotation.fieldName]
14
- ? utils_1.NotionUtils.fromNotionValue(page['properties'][annotation.fieldName], annotation)
15
- : undefined;
16
- return Object.assign(Object.assign({}, obj), { [annotation.propName]: value });
17
- }, { id: page.id });
18
- return this.Entity.from(obj);
19
- }
20
- toNotion(entity) {
21
- var _a;
22
- const annotations = (_a = this.Entity[decorators_1.NOTION_ANNOTATIONS]) !== null && _a !== void 0 ? _a : [];
23
- const data = annotations.reduce((obj, annotation) => (Object.assign(Object.assign({}, obj), { [annotation.fieldName]: utils_1.NotionUtils.toNotionValue(entity[annotation.propName], annotation) })), {});
24
- return (0, lodash_es_1.omitBy)(data, (value) => typeof value === 'undefined');
25
- }
26
- }
27
- exports.NotionConverter = NotionConverter;
28
- function createConverter(Entity) {
29
- class Converter extends NotionConverter {
30
- constructor() {
31
- super(...arguments);
32
- this.Entity = Entity;
33
- }
34
- }
35
- return new Converter();
36
- }
37
- //# sourceMappingURL=converter.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"converter.js","sourceRoot":"","sources":["../../../../../packages/@nx-ddd/notion/src/lib/converter/converter.ts"],"names":[],"mappings":";;;AA4BA,0CAMC;AAjCD,oCAAuC;AACvC,8CAAqE;AACrE,yCAAmC;AAEnC,MAAsB,eAAe;IAGnC,UAAU,CAAC,IAA6G;;QACtH,MAAM,WAAW,GAAuB,MAAA,IAAI,CAAC,MAAM,CAAC,+BAAkB,CAAC,mCAAI,EA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-1,5 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
- tslib_1.__exportStar(require("./converter"), exports);
5
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../packages/@nx-ddd/notion/src/lib/converter/index.ts"],"names":[],"mappings":";;;AAAA,sDAA4B"}
@@ -1,58 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Notion = exports.UniqueID = exports.Email = exports.PhoneNumber = exports.Select = exports.Date = exports.LastEditedTime = exports.CreatedTime = exports.Number = exports.Timestamp = exports.Rollup = exports.Formula = exports.Status = exports.Relation = exports.RichText = exports.Url = exports.Title = exports.NOTION_ANNOTATIONS = void 0;
4
- exports.NOTION_ANNOTATIONS = 'notion_annotations';
5
- function createDecorator(type, defaultOptions) {
6
- return (name, options) => {
7
- return (target, propName) => {
8
- var _a;
9
- var _b;
10
- const fieldName = name || propName;
11
- const ANNOTATION = { type, fieldName, propName, options: Object.assign(Object.assign({}, defaultOptions), options) };
12
- (_a = (_b = target.constructor)[exports.NOTION_ANNOTATIONS]) !== null && _a !== void 0 ? _a : (_b[exports.NOTION_ANNOTATIONS] = []);
13
- target.constructor[exports.NOTION_ANNOTATIONS].push(ANNOTATION);
14
- };
15
- };
16
- }
17
- exports.Title = createDecorator('title');
18
- exports.Url = createDecorator('url');
19
- exports.RichText = createDecorator('rich_text');
20
- exports.Relation = createDecorator('relation', { multi: false });
21
- exports.Status = createDecorator('status');
22
- exports.Formula = createDecorator('formula');
23
- exports.Rollup = createDecorator('rollup', { multi: false });
24
- exports.Timestamp = createDecorator('timestamp');
25
- exports.Number = createDecorator('number');
26
- exports.CreatedTime = createDecorator('created_time');
27
- exports.LastEditedTime = createDecorator('last_edited_time');
28
- exports.Date = createDecorator('date');
29
- exports.Select = createDecorator('select');
30
- exports.PhoneNumber = createDecorator('phone_number');
31
- exports.Email = createDecorator('email');
32
- exports.UniqueID = createDecorator('unique_id');
33
- // Not implemented below props!
34
- // export const Checkbox = createDecorator('checkbox');
35
- // export const CreatedBy = createDecorator('created_by');
36
- // export const Files = createDecorator('files');
37
- // export const LastEditedBy = createDecorator('last_edited_by');
38
- // export const MultiSelect = createDecorator('multi_select');
39
- // export const People = createDecorator('people');
40
- exports.Notion = {
41
- Title: exports.Title,
42
- Url: exports.Url,
43
- RichText: exports.RichText,
44
- Relation: exports.Relation,
45
- Status: exports.Status,
46
- Formula: exports.Formula,
47
- Rollup: exports.Rollup,
48
- Timestamp: exports.Timestamp,
49
- Number: exports.Number,
50
- CreatedTime: exports.CreatedTime,
51
- LastEditedTime: exports.LastEditedTime,
52
- Date: exports.Date,
53
- Select: exports.Select,
54
- PhoneNumber: exports.PhoneNumber,
55
- Email: exports.Email,
56
- UniqueID: exports.UniqueID,
57
- };
58
- //# sourceMappingURL=decorators.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"decorators.js","sourceRoot":"","sources":["../../../../../packages/@nx-ddd/notion/src/lib/decorators/decorators.ts"],"names":[],"mappings":";;;AAAa,QAAA,kBAAkB,GAAG,oBAAoB,CAAC;AAavD,SAAS,eAAe,CAA+B,IAAqB,EAAE,cAAkB;IAC9F,OAAO,CAAC,IAAa,EAAE,OAAoB,EAAE,EAAE;QAC7C,OAAO,CAAC,MAAW,EAAE,QAAgB,EAAE,EAAE;;;YACvC,MAAM,SAAS,GAAG,IAAI,IAAI,QAAQ,CAAC;YACnC,MAAM,UAAU,GAAwB,EAAC,IAAI,EAAE,SAAS,EAAE,QAAQ,EAAE,OAAO,kCAAM,cAAc,GAAK,OAAO,CAAC,EAAC,CAAC;YAC9G,YAAA,MAAM,CAAC,WAAW,EAAC,0BAAkB,wCAAlB,0BAAkB,IAAM,EAAE,EAAC;YAC9C,MAAM,CAAC,WAAW,CAAC,0BAAkB,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QAC1D,CAAC,CA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AAN,cAAM;IACN,OAAO,EAAP,eAAO;IACP,MAAM,EAAN,cAAM;IACN,SAAS,EAAT,iBAAS;IACT,MAAM,EAAN,cAAM;IACN,WAAW,EAAX,mBAAW;IACX,cAAc,EAAd,sBAAc;IACd,IAAI,EAAJ,YAAI;IACJ,MAAM,EAAN,cAAM;IACN,WAAW,EAAX,mBAAW;IACX,KAAK,EAAL,aAAK;IACL,QAAQ,EAAR,gBAAQ;CACT,CAAC"}
@@ -1,5 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
- tslib_1.__exportStar(require("./decorators"), exports);
5
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../packages/@nx-ddd/notion/src/lib/decorators/index.ts"],"names":[],"mappings":";;;AAAA,uDAA6B"}
package/index.js DELETED
@@ -1,10 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
- tslib_1.__exportStar(require("./converter"), exports);
5
- tslib_1.__exportStar(require("./decorators"), exports);
6
- tslib_1.__exportStar(require("./query"), exports);
7
- tslib_1.__exportStar(require("./query-builder"), exports);
8
- tslib_1.__exportStar(require("./repository"), exports);
9
- tslib_1.__exportStar(require("./utils"), exports);
10
- //# sourceMappingURL=index.js.map
package/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../packages/@nx-ddd/notion/src/lib/index.ts"],"names":[],"mappings":";;;AAAA,sDAA4B;AAC5B,uDAA6B;AAC7B,kDAAwB;AACxB,0DAAgC;AAChC,uDAA6B;AAC7B,kDAAwB"}
package/notion/index.js DELETED
@@ -1,5 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
- tslib_1.__exportStar(require("./notion.service"), exports);
5
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../packages/@nx-ddd/notion/src/lib/notion/index.ts"],"names":[],"mappings":";;;AAAA,2DAAiC"}
@@ -1,142 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.NotionService = exports.CacheAdapter = exports.NOTION_CONFIG = void 0;
4
- exports.provideNotionService = provideNotionService;
5
- const tslib_1 = require("tslib");
6
- const core_1 = require("@angular/core");
7
- const client_1 = require("@notionhq/client");
8
- const notion_service_1 = require("./notion.service");
9
- const node_localstorage_1 = require("node-localstorage");
10
- const CryptoJS = tslib_1.__importStar(require("crypto-js"));
11
- exports.NOTION_CONFIG = new core_1.InjectionToken('NOTION_CONFIG');
12
- function provideNotionService(useFactory) {
13
- return [
14
- { provide: exports.NOTION_CONFIG, useFactory },
15
- { provide: notion_service_1.NOTION_SERVICE, useClass: NotionService },
16
- ];
17
- }
18
- let CacheAdapter = class CacheAdapter {
19
- constructor() {
20
- this.localStorage = global.localStorage || new node_localstorage_1.LocalStorage('node_modules/.cache/@nx-ddd/notion', 5 * 1024 * 1024 * 1024);
21
- }
22
- get(keyOrObj) {
23
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
24
- const key = this.makeKey(keyOrObj);
25
- return this.parseJson(this.localStorage.getItem(key));
26
- });
27
- }
28
- set(keyOrObj, value) {
29
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
30
- const key = this.makeKey(keyOrObj);
31
- this.localStorage.setItem(key, this.makeJson(value));
32
- });
33
- }
34
- remove(keyOrObj) {
35
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
36
- const key = this.makeKey(keyOrObj);
37
- this.localStorage.removeItem(key);
38
- });
39
- }
40
- call(props, callback) {
41
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
42
- const key = this.makeKey(props);
43
- let value = yield this.get(key);
44
- if (value)
45
- return value;
46
- value = yield callback(props);
47
- yield this.set(key, value);
48
- return value;
49
- });
50
- }
51
- makeKey(keyOrObj) {
52
- const value = typeof keyOrObj === 'string' ? keyOrObj : JSON.stringify(keyOrObj);
53
- return CryptoJS.SHA256(value).toString();
54
- }
55
- makeJson(valueOrObj) {
56
- return JSON.stringify(valueOrObj);
57
- }
58
- parseJson(value) {
59
- return JSON.parse(value);
60
- }
61
- };
62
- exports.CacheAdapter = CacheAdapter;
63
- exports.CacheAdapter = CacheAdapter = tslib_1.__decorate([
64
- (0, core_1.Injectable)({ providedIn: 'root' })
65
- ], CacheAdapter);
66
- let NotionService = class NotionService {
67
- constructor() {
68
- this.config = (0, core_1.inject)(exports.NOTION_CONFIG);
69
- this.notionClient = new client_1.Client({ auth: this.config.token });
70
- this.cache = (0, core_1.inject)(CacheAdapter);
71
- }
72
- retrievePage(pageId) {
73
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
74
- return this.cache.call(pageId, () => tslib_1.__awaiter(this, void 0, void 0, function* () {
75
- return this.notionClient.pages.retrieve({ page_id: pageId });
76
- }));
77
- });
78
- }
79
- updatePage(pageId, properties) {
80
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
81
- const response = yield this.notionClient.pages.update({
82
- page_id: pageId,
83
- properties,
84
- });
85
- return response;
86
- });
87
- }
88
- deletePage(pageId) {
89
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
90
- yield this.notionClient.pages.update({
91
- page_id: pageId,
92
- archived: true,
93
- });
94
- });
95
- }
96
- retrieveDatabase(databaseId) {
97
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
98
- // return this.cache.call(databaseId, async () => {
99
- return this.notionClient.databases.retrieve({ database_id: databaseId });
100
- // });
101
- });
102
- }
103
- updateDatabase(databaseId, properties) {
104
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
105
- console.debug('properties:', properties);
106
- const response = yield this.notionClient.databases.update({
107
- database_id: databaseId,
108
- properties,
109
- });
110
- yield this.cache.remove(databaseId);
111
- return response;
112
- });
113
- }
114
- retrieveBlock(blockId) {
115
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
116
- return this.cache.call(blockId, () => tslib_1.__awaiter(this, void 0, void 0, function* () {
117
- return this.notionClient.blocks.retrieve({ block_id: blockId });
118
- }));
119
- });
120
- }
121
- search(params) {
122
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
123
- return this.cache.call(params, () => {
124
- return this.notionClient.search(params);
125
- });
126
- });
127
- }
128
- queryDatabase(databaseId, filter) {
129
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
130
- const response = yield this.notionClient.databases.query({
131
- database_id: databaseId,
132
- filter,
133
- });
134
- return response.results;
135
- });
136
- }
137
- };
138
- exports.NotionService = NotionService;
139
- exports.NotionService = NotionService = tslib_1.__decorate([
140
- (0, core_1.Injectable)({ providedIn: 'root' })
141
- ], NotionService);
142
- //# sourceMappingURL=notion.service.impl.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"notion.service.impl.js","sourceRoot":"","sources":["../../../../../packages/@nx-ddd/notion/src/lib/notion/notion.service.impl.ts"],"names":[],"mappings":";;;AAYA,oDAKC;;AAjBD,wCAA6E;AAC7E,6CAA0C;AAC1C,qDAAkD;AAClD,yDAAiD;AACjD,4DAAsC;AAMzB,QAAA,aAAa,GAAG,IAAI,qBAAc,CAAe,eAAe,CAAC,CAAC;AAE/E,SAAgB,oBAAoB,CAAC,UAA8B;IACjE,OAAO;QACL,EAAE,OAAO,EAAE,qBAAa,EAAE,UAAU,EAAE;QACtC,EAAE,OAAO,EAAE,+BAAc,EAAE,QAAQ,EAAE,aAAa,EAAE;KACrD,CAAC;AACJ,CAAC;AAEM,IAAM,YAAY,GAAlB,MAAM,YAAY;IAAlB;QACK,iBAAY,GAAiB,MAAM,CAAC,YAAY,IAAI,IAAI,gCAAY,CAAC,oCAAoC,EAAE,CAAC,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC,CAAC;IAsC/I,CAAC;IApCO,GAAG,CAAI,QAAyB;;YACpC,MAAM,GAAG,GAAG,IAAI,C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AE,CAAC;GACtB,aAAa,CA6DzB"}
@@ -1,12 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.NOTION_CONFIG = exports.NOTION_SERVICE = void 0;
4
- exports.injectNotion = injectNotion;
5
- const core_1 = require("@angular/core");
6
- exports.NOTION_SERVICE = new core_1.InjectionToken('NOTION_SERVICE');
7
- exports.NOTION_CONFIG = new core_1.InjectionToken('NOTION_CONFIG');
8
- function injectNotion() {
9
- var _a;
10
- return (_a = (0, core_1.inject)(exports.NOTION_SERVICE, { optional: true })) !== null && _a !== void 0 ? _a : null;
11
- }
12
- //# sourceMappingURL=notion.service.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"notion.service.js","sourceRoot":"","sources":["../../../../../packages/@nx-ddd/notion/src/lib/notion/notion.service.ts"],"names":[],"mappings":";;;AAUA,oCAEC;AAZD,wCAAuD;AAO1C,QAAA,cAAc,GAAG,IAAI,qBAAc,CAAgB,gBAAgB,CAAC,CAAC;AACrE,QAAA,aAAa,GAAG,IAAI,qBAAc,CAAe,eAAe,CAAC,CAAC;AAE/E,SAAgB,YAAY;;IAC1B,OAAO,MAAA,IAAA,aAAM,EAAC,sBAAc,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,mCAAI,IAAI,CAAC;AAC5D,CAAC"}
package/query/index.js DELETED
@@ -1,5 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
- tslib_1.__exportStar(require("./query"), exports);
5
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../packages/@nx-ddd/notion/src/lib/query/index.ts"],"names":[],"mappings":";;;AAAA,kDAAwB"}