@nx-ddd/notion 0.0.0-PLACEHOLDER

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 (44) hide show
  1. package/README.md +11 -0
  2. package/_testing/entity.d.ts +20 -0
  3. package/_testing/entity.js +44 -0
  4. package/_testing/entity.js.map +1 -0
  5. package/_testing/index.d.ts +1 -0
  6. package/_testing/index.js +5 -0
  7. package/_testing/index.js.map +1 -0
  8. package/converter/converter.d.ts +8 -0
  9. package/converter/converter.js +34 -0
  10. package/converter/converter.js.map +1 -0
  11. package/converter/index.d.ts +1 -0
  12. package/converter/index.js +5 -0
  13. package/converter/index.js.map +1 -0
  14. package/decorators/decorators.d.ts +46 -0
  15. package/decorators/decorators.js +31 -0
  16. package/decorators/decorators.js.map +1 -0
  17. package/decorators/index.d.ts +1 -0
  18. package/decorators/index.js +5 -0
  19. package/decorators/index.js.map +1 -0
  20. package/index.d.ts +6 -0
  21. package/index.js +10 -0
  22. package/index.js.map +1 -0
  23. package/package.json +15 -0
  24. package/query/index.d.ts +1 -0
  25. package/query/index.js +5 -0
  26. package/query/index.js.map +1 -0
  27. package/query/query.d.ts +174 -0
  28. package/query/query.js +120 -0
  29. package/query/query.js.map +1 -0
  30. package/query-builder/index.d.ts +1 -0
  31. package/query-builder/index.js +5 -0
  32. package/query-builder/index.js.map +1 -0
  33. package/query-builder/query-builder.d.ts +27 -0
  34. package/query-builder/query-builder.js +30 -0
  35. package/query-builder/query-builder.js.map +1 -0
  36. package/repository/index.d.ts +1 -0
  37. package/repository/index.js +5 -0
  38. package/repository/index.js.map +1 -0
  39. package/repository/repository.d.ts +31 -0
  40. package/repository/repository.js +79 -0
  41. package/repository/repository.js.map +1 -0
  42. package/utils.d.ts +195 -0
  43. package/utils.js +121 -0
  44. package/utils.js.map +1 -0
package/README.md ADDED
@@ -0,0 +1,11 @@
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/).
@@ -0,0 +1,20 @@
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
+ }
@@ -0,0 +1,44 @@
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
+ tslib_1.__decorate([
13
+ (0, decorators_1.Title)({ name: 'タイトル' }),
14
+ tslib_1.__metadata("design:type", String)
15
+ ], Entity.prototype, "title", void 0);
16
+ tslib_1.__decorate([
17
+ (0, decorators_1.Status)({ name: 'ステータス' }),
18
+ tslib_1.__metadata("design:type", String)
19
+ ], Entity.prototype, "status", void 0);
20
+ tslib_1.__decorate([
21
+ (0, decorators_1.Relation)({ name: '一次選考' }),
22
+ tslib_1.__metadata("design:type", Array)
23
+ ], Entity.prototype, "firstSelectionIds", void 0);
24
+ tslib_1.__decorate([
25
+ (0, decorators_1.Formula)({ name: '一次選考開始文(Discord)' }),
26
+ tslib_1.__metadata("design:type", String)
27
+ ], Entity.prototype, "discordFirstSelectionMessage", void 0);
28
+ tslib_1.__decorate([
29
+ (0, decorators_1.Formula)({ name: '二次選考開始文(Discord)' }),
30
+ tslib_1.__metadata("design:type", String)
31
+ ], Entity.prototype, "discordSecondSelectionMessage", void 0);
32
+ tslib_1.__decorate([
33
+ (0, decorators_1.RichText)({ name: 'discordChannelId' }),
34
+ tslib_1.__metadata("design:type", String)
35
+ ], Entity.prototype, "discordChannelId", void 0);
36
+ exports.Entity = Entity;
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
@@ -0,0 +1 @@
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;AArBC;IAAC,IAAA,kBAAK,EAAC,EAAC,IAAI,EAAE,MAAM,EAAC,CAAC;;qCACR;AAEd;IAAC,IAAA,mBAAM,EAAC,EAAC,IAAI,EAAE,OAAO,EAAC,CAAC;;sCACT;AAEf;IAAC,IAAA,qBAAQ,EAAC,EAAC,IAAI,EAAE,MAAM,EAAC,CAAC;;iDACG;AAE5B;IAAC,IAAA,oBAAO,EAAC,EAAC,IAAI,EAAE,kBAAkB,EAAC,CAAC;;4DACC;AAErC;IAAC,IAAA,oBAAO,EAAC,EAAC,IAAI,EAAE,kBAAkB,EAAC,CAAC;;6DACE;AAEtC;IAAC,IAAA,qBAAQ,EAAC,EAAC,IAAI,EAAE,kBAAkB,EAAC,CAAC;;gDACZ;AAjB3B,wBAsBC;AAED,MAAa,eAAgB,SAAQ,2BAAuB;IAA5D;;QACY,WAAM,GAAG,MAAM,CAAC;IAC5B,CAAC;CAAA;AAFD,0CAEC"}
@@ -0,0 +1 @@
1
+ export * from './entity';
@@ -0,0 +1,5 @@
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
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../packages/@nx-ddd/notion/src/lib/_testing/index.ts"],"names":[],"mappings":";;;AAAA,mDAAyB"}
@@ -0,0 +1,8 @@
1
+ import { PageObjectResponse, PartialPageObjectResponse } from "@notionhq/client/build/src/api-endpoints";
2
+ import { Converter } from '@nx-ddd/common/infrastructure/converter';
3
+ export declare abstract class NotionConverter<E> extends Converter<E> {
4
+ protected abstract Entity: any;
5
+ fromRecord(page: PageObjectResponse | PartialPageObjectResponse): E;
6
+ toRecord(entity: Partial<E>): object;
7
+ }
8
+ export declare function createConverter<E = any>(Entity: any): NotionConverter<E>;
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createConverter = exports.NotionConverter = void 0;
4
+ const converter_1 = require("@nx-ddd/common/infrastructure/converter");
5
+ const utils_1 = require("../utils");
6
+ const decorators_1 = require("../decorators");
7
+ const lodash_1 = require("lodash");
8
+ class NotionConverter extends converter_1.Converter {
9
+ fromRecord(page) {
10
+ const annotations = this.Entity[decorators_1.NOTION_ANNOTATIONS];
11
+ const obj = annotations.reduce((obj, { type, fieldName, propName }) => {
12
+ const value = page['properties'][fieldName] ? utils_1.NotionUtils.fromNotionValue(page['properties'][fieldName]) : undefined;
13
+ return Object.assign(Object.assign({}, obj), { [propName]: value });
14
+ }, { id: page.id });
15
+ return this.Entity.from(obj);
16
+ }
17
+ toRecord(entity) {
18
+ const annotations = this.Entity[decorators_1.NOTION_ANNOTATIONS];
19
+ const data = annotations.reduce((obj, { type, fieldName, propName }) => (Object.assign(Object.assign({}, obj), { [fieldName]: utils_1.NotionUtils.toNotionValue(entity[propName], type) })), {});
20
+ return (0, lodash_1.omitBy)(data, (value) => typeof value === 'undefined');
21
+ }
22
+ }
23
+ exports.NotionConverter = NotionConverter;
24
+ function createConverter(Entity) {
25
+ class Converter extends NotionConverter {
26
+ constructor() {
27
+ super(...arguments);
28
+ this.Entity = Entity;
29
+ }
30
+ }
31
+ return new Converter();
32
+ }
33
+ exports.createConverter = createConverter;
34
+ //# sourceMappingURL=converter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"converter.js","sourceRoot":"","sources":["../../../../../packages/@nx-ddd/notion/src/lib/converter/converter.ts"],"names":[],"mappings":";;;AACA,uEAAoE;AACpE,oCAAuC;AACvC,8CAAqE;AACrE,mCAAgC;AAEhC,MAAsB,eAAmB,SAAQ,qBAAY;IAG3D,UAAU,CAAC,IAAoD;QAC7D,MAAM,WAAW,GAAuB,IAAI,CAAC,MAAM,CAAC,+BAAkB,CAAC,CAAC;QACxE,MAAM,GAAG,GAAG,WAAW,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,EAAC,IAAI,EAAE,SAAS,EAAE,QAAQ,EAAC,EAAE,EAAE;YAClE,MAAM,KAAK,GAAG,IAAI,CAAC,YAAY,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,mBAAW,CAAC,eAAe,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;YACrH,uCAAW,GAAG,KAAE,CAAC,QAAQ,CAAC,EAAE,KAAK,IAAE;QACrC,CAAC,EAAE,EAAC,EAAE,EAAE,IAAI,CAAC,EAAE,EAAC,CAAC,CAAC;QAClB,OAAQ,IAAI,CAAC,MAAc,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACxC,CAAC;IAED,QAAQ,CAAC,MAAkB;QACzB,MAAM,WAAW,GAAuB,IAAI,CAAC,MAAM,CAAC,+BAAkB,CAAC,CAAC;QACxE,MAAM,IAAI,GAAG,WAAW,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,EAAC,IAAI,EAAE,SAAS,EAAE,QAAQ,EAAC,EAAE,EAAE,CAAC,iCACjE,GAAG,KAAE,CAAC,SAAS,CAAC,EAAE,mBAAW,CAAC,aAAa,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,IAAI,CAAC,IACtE,EAAE,EAAE,CAAC,CAAC;QACR,OAAO,IAAA,eAAM,EAAC,IAAI,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,OAAO,KAAK,KAAK,WAAW,CAAC,CAAC;IAC/D,CAAC;CACF;AAnBD,0CAmBC;AAED,SAAgB,eAAe,CAAU,MAAW;IAClD,MAAM,SAAU,SAAQ,eAAkB;QAA1C;;YACY,WAAM,GAAG,MAAM,CAAC;QAC5B,CAAC;KAAA;IAED,OAAO,IAAI,SAAS,EAAE,CAAC;AACzB,CAAC;AAND,0CAMC"}
@@ -0,0 +1 @@
1
+ export * from './converter';
@@ -0,0 +1,5 @@
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
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../packages/@nx-ddd/notion/src/lib/converter/index.ts"],"names":[],"mappings":";;;AAAA,sDAA4B"}
@@ -0,0 +1,46 @@
1
+ export declare const NOTION_ANNOTATIONS = "notion_annotations";
2
+ export declare type NotionFieldType = 'title' | 'url' | 'rich_text' | 'relation' | 'status' | 'formula' | 'rollup' | 'timestamp' | 'number' | 'created_time' | 'last_edited_time' | 'date' | 'select';
3
+ export interface NotionAnnotation {
4
+ type: NotionFieldType;
5
+ fieldName: string;
6
+ propName: string;
7
+ }
8
+ export declare const Title: (props?: {
9
+ name?: string;
10
+ }) => (target: any, propName: string) => void;
11
+ export declare const Url: (props?: {
12
+ name?: string;
13
+ }) => (target: any, propName: string) => void;
14
+ export declare const RichText: (props?: {
15
+ name?: string;
16
+ }) => (target: any, propName: string) => void;
17
+ export declare const Relation: (props?: {
18
+ name?: string;
19
+ }) => (target: any, propName: string) => void;
20
+ export declare const Status: (props?: {
21
+ name?: string;
22
+ }) => (target: any, propName: string) => void;
23
+ export declare const Formula: (props?: {
24
+ name?: string;
25
+ }) => (target: any, propName: string) => void;
26
+ export declare const Rollup: (props?: {
27
+ name?: string;
28
+ }) => (target: any, propName: string) => void;
29
+ export declare const Timestamp: (props?: {
30
+ name?: string;
31
+ }) => (target: any, propName: string) => void;
32
+ export declare const Number: (props?: {
33
+ name?: string;
34
+ }) => (target: any, propName: string) => void;
35
+ export declare const CreatedTime: (props?: {
36
+ name?: string;
37
+ }) => (target: any, propName: string) => void;
38
+ export declare const LastEditedTime: (props?: {
39
+ name?: string;
40
+ }) => (target: any, propName: string) => void;
41
+ export declare const Date: (props?: {
42
+ name?: string;
43
+ }) => (target: any, propName: string) => void;
44
+ export declare const Select: (props?: {
45
+ name?: string;
46
+ }) => (target: any, propName: string) => void;
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ 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
+ ;
6
+ function createDecorator(type) {
7
+ return (props) => {
8
+ return (target, propName) => {
9
+ var _a;
10
+ var _b;
11
+ const fieldName = props.name || propName;
12
+ const ANNOTATION = { type, fieldName, propName };
13
+ (_a = (_b = target.constructor)[exports.NOTION_ANNOTATIONS]) !== null && _a !== void 0 ? _a : (_b[exports.NOTION_ANNOTATIONS] = []);
14
+ target.constructor[exports.NOTION_ANNOTATIONS].push(ANNOTATION);
15
+ };
16
+ };
17
+ }
18
+ exports.Title = createDecorator('title');
19
+ exports.Url = createDecorator('url');
20
+ exports.RichText = createDecorator('rich_text');
21
+ exports.Relation = createDecorator('relation');
22
+ exports.Status = createDecorator('status');
23
+ exports.Formula = createDecorator('formula');
24
+ exports.Rollup = createDecorator('rollup');
25
+ exports.Timestamp = createDecorator('timestamp');
26
+ exports.Number = createDecorator('number');
27
+ exports.CreatedTime = createDecorator('created_time');
28
+ exports.LastEditedTime = createDecorator('last_edited_time');
29
+ exports.Date = createDecorator('date');
30
+ exports.Select = createDecorator('select');
31
+ //# sourceMappingURL=decorators.js.map
@@ -0,0 +1 @@
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;AAQtD,CAAC;AAEF,SAAS,eAAe,CAAC,IAAqB;IAC5C,OAAO,CAAC,KAAuB,EAAE,EAAE;QACjC,OAAO,CAAC,MAAW,EAAE,QAAgB,EAAE,EAAE;;;YACvC,MAAM,SAAS,GAAG,KAAK,CAAC,IAAI,IAAI,QAAQ,CAAC;YACzC,MAAM,UAAU,GAAqB,EAAC,IAAI,EAAE,SAAS,EAAE,QAAQ,EAAC,CAAC;YACjE,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,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC;AAEY,QAAA,KAAK,GAAG,eAAe,CAAC,OAAO,CAAC,CAAC;AACjC,QAAA,GAAG,GAAG,eAAe,CAAC,KAAK,CAAC,CAAC;AAC7B,QAAA,QAAQ,GAAG,eAAe,CAAC,WAAW,CAAC,CAAC;AACxC,QAAA,QAAQ,GAAG,eAAe,CAAC,UAAU,CAAC,CAAC;AACvC,QAAA,MAAM,GAAG,eAAe,CAAC,QAAQ,CAAC,CAAC;AACnC,QAAA,OAAO,GAAG,eAAe,CAAC,SAAS,CAAC,CAAC;AACrC,QAAA,MAAM,GAAG,eAAe,CAAC,QAAQ,CAAC,CAAC;AACnC,QAAA,SAAS,GAAG,eAAe,CAAC,WAAW,CAAC,CAAC;AACzC,QAAA,MAAM,GAAG,eAAe,CAAC,QAAQ,CAAC,CAAC;AACnC,QAAA,WAAW,GAAG,eAAe,CAAC,cAAc,CAAC,CAAC;AAC9C,QAAA,cAAc,GAAG,eAAe,CAAC,kBAAkB,CAAC,CAAC;AACrD,QAAA,IAAI,GAAG,eAAe,CAAC,MAAM,CAAC,CAAC;AAC/B,QAAA,MAAM,GAAG,eAAe,CAAC,QAAQ,CAAC,CAAC"}
@@ -0,0 +1 @@
1
+ export * from './decorators';
@@ -0,0 +1,5 @@
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
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../packages/@nx-ddd/notion/src/lib/decorators/index.ts"],"names":[],"mappings":";;;AAAA,uDAA6B"}
package/index.d.ts ADDED
@@ -0,0 +1,6 @@
1
+ export * from './converter';
2
+ export * from './decorators';
3
+ export * from './query';
4
+ export * from './query-builder';
5
+ export * from './repository';
6
+ export * from './utils';
package/index.js ADDED
@@ -0,0 +1,10 @@
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 ADDED
@@ -0,0 +1 @@
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/package.json ADDED
@@ -0,0 +1,15 @@
1
+ {
2
+ "name": "@nx-ddd/notion",
3
+ "version": "0.0.0-PLACEHOLDER",
4
+ "main": "./index.js",
5
+ "types": "./index.d.ts",
6
+ "dependencies": {},
7
+ "peerDependencies": {
8
+ "@notionhq/client": "^2.2.2",
9
+ "@nx-ddd/common": "0.0.0-PLACEHOLDER",
10
+ "@nx-ddd/core": "0.0.0-PLACEHOLDER",
11
+ "injection-js": "^2.4.0",
12
+ "reflect-metadata": "^0.1.13",
13
+ "tslib": "^2.0.0"
14
+ }
15
+ }
@@ -0,0 +1 @@
1
+ export * from './query';
package/query/index.js ADDED
@@ -0,0 +1,5 @@
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
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../packages/@nx-ddd/notion/src/lib/query/index.ts"],"names":[],"mappings":";;;AAAA,kDAAwB"}
@@ -0,0 +1,174 @@
1
+ import { Entity } from "@nx-ddd/common/domain/models";
2
+ declare type Evaluation = '==' | '>' | '>=' | '<' | '<=' | '!=' | 'in';
3
+ export declare class N {
4
+ static RollupPropQuery(property: string, evaluation: Evaluation, value: string | number): {
5
+ property: string;
6
+ rollup: {
7
+ every: {
8
+ rich_text: {
9
+ equals: string | number;
10
+ };
11
+ };
12
+ };
13
+ };
14
+ static FormulaQuery(property: string, evaluation: Evaluation, value: string | number): {
15
+ property: string;
16
+ formula: {};
17
+ };
18
+ static LastEditedTime(property: string, evaluation: Evaluation, value: string | number): {
19
+ timestamp: string;
20
+ last_edited_time: {
21
+ [x: string]: string | number;
22
+ };
23
+ };
24
+ static Timestamp(property: string, evaluation: Evaluation, value: string): {
25
+ property: string;
26
+ timestamp: {
27
+ [x: string]: string;
28
+ };
29
+ };
30
+ static Status(property: string, evaluation: Evaluation, value: string): {
31
+ property: string;
32
+ status: {
33
+ [x: string]: string;
34
+ };
35
+ };
36
+ static Relation(property: string, evaluation: Evaluation, value: string): {
37
+ property: string;
38
+ relation: {
39
+ [x: string]: string;
40
+ };
41
+ };
42
+ }
43
+ export declare abstract class NotionBaseQuery {
44
+ type: 'and' | 'or' | 'filter' | 'sort';
45
+ abstract build(): any;
46
+ }
47
+ export declare class NotionFilter extends NotionBaseQuery {
48
+ propertyType: any;
49
+ propertyName: string;
50
+ evaluation: Evaluation;
51
+ value: string | number;
52
+ readonly type: 'filter';
53
+ constructor(propertyType: any, propertyName: string, evaluation: Evaluation, value: string | number);
54
+ build(): {
55
+ property: string;
56
+ rollup: {
57
+ every: {
58
+ rich_text: {
59
+ equals: string | number;
60
+ };
61
+ };
62
+ };
63
+ } | {
64
+ property: string;
65
+ formula: {};
66
+ } | {
67
+ timestamp: string;
68
+ last_edited_time: {
69
+ [x: string]: string | number;
70
+ };
71
+ } | {
72
+ property: string;
73
+ status: {
74
+ [x: string]: string;
75
+ };
76
+ } | {
77
+ property: string;
78
+ relation: {
79
+ [x: string]: string;
80
+ };
81
+ };
82
+ }
83
+ export declare class NotionSort extends NotionBaseQuery {
84
+ property: string;
85
+ direction: 'asc' | 'desc';
86
+ readonly type: 'sort';
87
+ constructor(property: string, direction?: 'asc' | 'desc');
88
+ build(): {
89
+ property: string;
90
+ direction: string;
91
+ };
92
+ }
93
+ export declare class NotionAnd extends NotionBaseQuery {
94
+ readonly type: 'and';
95
+ arr: NotionFilter[];
96
+ constructor(...filters: NotionFilter[]);
97
+ build(): {
98
+ and: ({
99
+ property: string;
100
+ rollup: {
101
+ every: {
102
+ rich_text: {
103
+ equals: string | number;
104
+ };
105
+ };
106
+ };
107
+ } | {
108
+ property: string;
109
+ formula: {};
110
+ } | {
111
+ timestamp: string;
112
+ last_edited_time: {
113
+ [x: string]: string | number;
114
+ };
115
+ } | {
116
+ property: string;
117
+ status: {
118
+ [x: string]: string;
119
+ };
120
+ } | {
121
+ property: string;
122
+ relation: {
123
+ [x: string]: string;
124
+ };
125
+ })[];
126
+ };
127
+ }
128
+ export declare class NotionOr extends NotionBaseQuery {
129
+ readonly type: 'or';
130
+ arr: NotionFilter[];
131
+ constructor(...filters: NotionFilter[]);
132
+ build(): {
133
+ or: ({
134
+ property: string;
135
+ rollup: {
136
+ every: {
137
+ rich_text: {
138
+ equals: string | number;
139
+ };
140
+ };
141
+ };
142
+ } | {
143
+ property: string;
144
+ formula: {};
145
+ } | {
146
+ timestamp: string;
147
+ last_edited_time: {
148
+ [x: string]: string | number;
149
+ };
150
+ } | {
151
+ property: string;
152
+ status: {
153
+ [x: string]: string;
154
+ };
155
+ } | {
156
+ property: string;
157
+ relation: {
158
+ [x: string]: string;
159
+ };
160
+ })[];
161
+ };
162
+ }
163
+ export declare const Query: <E_1 extends {
164
+ new (): Entity<any>;
165
+ from<E extends Entity<string> = any>(obj: Partial<import("@nx-ddd/common/domain/models").OmitGetter<E>>): E;
166
+ fromObj<T extends Entity<string> = Entity<string>>(obj: object): T;
167
+ toObj(entity: Entity<string>): Entity<string>;
168
+ }>(Entity: E_1) => {
169
+ Filter: (_propName: string, evaluation: Evaluation, value: string | number) => NotionFilter;
170
+ OrderBy: (_propName: string, direction: 'asc' | 'desc') => NotionSort;
171
+ And: (...args: NotionFilter[]) => NotionAnd;
172
+ Or: (...args: NotionFilter[]) => NotionOr;
173
+ };
174
+ export {};
package/query/query.js ADDED
@@ -0,0 +1,120 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Query = exports.NotionOr = exports.NotionAnd = exports.NotionSort = exports.NotionFilter = exports.NotionBaseQuery = exports.N = void 0;
4
+ const decorators_1 = require("../decorators");
5
+ class N {
6
+ static RollupPropQuery(property, evaluation, value) {
7
+ return { property, rollup: { every: { rich_text: { equals: value } } } };
8
+ }
9
+ static FormulaQuery(property, evaluation, value) {
10
+ return { property, formula: {} };
11
+ }
12
+ static LastEditedTime(property, evaluation, value) {
13
+ const query = evaluation === '>' ? 'after'
14
+ : evaluation === '<' ? 'before'
15
+ : evaluation === '==' ? 'equals'
16
+ : evaluation === '<=' ? 'on_or_before'
17
+ : evaluation === '>=' ? 'on_or_after'
18
+ : evaluation === '!=' ? '' : '';
19
+ return { timestamp: 'last_edited_time', last_edited_time: { [query]: value } };
20
+ }
21
+ static Timestamp(property, evaluation, value) {
22
+ const query = evaluation === '>' ? 'after'
23
+ : evaluation === '<' ? 'before'
24
+ : evaluation === '==' ? 'equals'
25
+ : evaluation === '<=' ? 'on_or_before'
26
+ : evaluation === '>=' ? 'on_or_after'
27
+ : evaluation === '!=' ? '' : '';
28
+ return { property, timestamp: { [query]: value } };
29
+ }
30
+ static Status(property, evaluation, value) {
31
+ const query = evaluation === '==' ? 'equals' : '';
32
+ // TODO(nontangent): 'ステータス'を修正
33
+ return { property: 'ステータス', status: { [query]: value } };
34
+ }
35
+ static Relation(property, evaluation, value) {
36
+ const query = evaluation === 'in' ? 'contains' : '';
37
+ return { property, relation: { [query]: value } };
38
+ }
39
+ }
40
+ exports.N = N;
41
+ class NotionBaseQuery {
42
+ }
43
+ exports.NotionBaseQuery = NotionBaseQuery;
44
+ class NotionFilter extends NotionBaseQuery {
45
+ constructor(propertyType, propertyName, evaluation, value) {
46
+ super();
47
+ this.propertyType = propertyType;
48
+ this.propertyName = propertyName;
49
+ this.evaluation = evaluation;
50
+ this.value = value;
51
+ this.type = 'filter';
52
+ }
53
+ build() {
54
+ switch (this.propertyName) {
55
+ case 'last_edited_time': return N.LastEditedTime(this.propertyName, this.evaluation, this.value);
56
+ }
57
+ switch (this.propertyType) {
58
+ case 'rollup': return N.RollupPropQuery(this.propertyName, this.evaluation, this.value);
59
+ case 'formula': return N.FormulaQuery(this.propertyName, this.evaluation, this.value);
60
+ case 'status': return N.Status(this.propertyName, this.evaluation, this.value);
61
+ case 'relation': return N.Relation(this.propertyName, this.evaluation, this.value);
62
+ }
63
+ }
64
+ }
65
+ exports.NotionFilter = NotionFilter;
66
+ class NotionSort extends NotionBaseQuery {
67
+ constructor(property, direction = 'asc') {
68
+ super();
69
+ this.property = property;
70
+ this.direction = direction;
71
+ this.type = 'sort';
72
+ }
73
+ build() {
74
+ return {
75
+ property: this.property,
76
+ direction: this.direction === 'asc' ? 'ascending' : 'descending',
77
+ };
78
+ }
79
+ }
80
+ exports.NotionSort = NotionSort;
81
+ class NotionAnd extends NotionBaseQuery {
82
+ constructor(...filters) {
83
+ super();
84
+ this.type = 'and';
85
+ this.arr = filters;
86
+ }
87
+ build() {
88
+ return { and: this.arr.map(filter => filter.build()) };
89
+ }
90
+ }
91
+ exports.NotionAnd = NotionAnd;
92
+ class NotionOr extends NotionBaseQuery {
93
+ constructor(...filters) {
94
+ super();
95
+ this.type = 'or';
96
+ this.arr = filters;
97
+ }
98
+ build() {
99
+ return { or: this.arr.map(filter => filter.build()) };
100
+ }
101
+ }
102
+ exports.NotionOr = NotionOr;
103
+ const Query = (Entity) => {
104
+ const Filter = (_propName, evaluation, value) => {
105
+ var _a;
106
+ const annotation = Entity[decorators_1.NOTION_ANNOTATIONS].find(({ propName }) => propName === _propName);
107
+ // TODO(nontangent): propertyが無いときはエラーにした方が良いかもしれない。
108
+ return new NotionFilter(annotation === null || annotation === void 0 ? void 0 : annotation.type, (_a = annotation === null || annotation === void 0 ? void 0 : annotation.fieldName) !== null && _a !== void 0 ? _a : _propName, evaluation, value);
109
+ };
110
+ const OrderBy = (_propName, direction) => {
111
+ var _a;
112
+ const annotation = Entity[decorators_1.NOTION_ANNOTATIONS].find(({ propName }) => propName === _propName);
113
+ return new NotionSort((_a = annotation === null || annotation === void 0 ? void 0 : annotation.fieldName) !== null && _a !== void 0 ? _a : _propName, direction);
114
+ };
115
+ const And = (...args) => new NotionAnd(...args);
116
+ const Or = (...args) => new NotionOr(...args);
117
+ return { Filter, OrderBy, And, Or };
118
+ };
119
+ exports.Query = Query;
120
+ //# sourceMappingURL=query.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"query.js","sourceRoot":"","sources":["../../../../../packages/@nx-ddd/notion/src/lib/query/query.ts"],"names":[],"mappings":";;;AAAA,8CAAqE;AAKrE,MAAa,CAAC;IACZ,MAAM,CAAC,eAAe,CAAC,QAAgB,EAAE,UAAsB,EAAE,KAAsB;QACrF,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,KAAK,EAAE,EAAE,SAAS,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,EAAE,EAAE,EAAE,CAAC;IAC3E,CAAC;IAED,MAAM,CAAC,YAAY,CAAC,QAAgB,EAAE,UAAsB,EAAE,KAAsB;QAClF,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,EAAE,EAAC,CAAC;IAClC,CAAC;IAED,MAAM,CAAC,cAAc,CAAC,QAAgB,EAAE,UAAsB,EAAE,KAAsB;QACpF,MAAM,KAAK,GAAG,UAAU,KAAK,GAAG,CAAC,CAAC,CAAC,OAAO;YACxC,CAAC,CAAC,UAAU,KAAK,GAAG,CAAC,CAAC,CAAC,QAAQ;gBAC/B,CAAC,CAAC,UAAU,KAAK,IAAI,CAAC,CAAC,CAAC,QAAQ;oBAChC,CAAC,CAAC,UAAU,KAAK,IAAI,CAAC,CAAC,CAAC,cAAc;wBACtC,CAAC,CAAC,UAAU,KAAK,IAAI,CAAC,CAAC,CAAC,aAAa;4BACrC,CAAC,CAAC,UAAU,KAAK,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAClC,OAAO,EAAE,SAAS,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,EAAC,CAAC,KAAK,CAAC,EAAE,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C;QAC7G,oDAAoD;QACpD,OAAO,IAAI,YAAY,CAAC,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAE,IAAI,EAAE,MAAA,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAE,SAAS,mCAAI,SAAS,EAAE,UAAU,EAAE,KAAK,CAAC,CAAC;IACnG,CAAC,CAAC;IACF,MAAM,OAAO,GAAG,CAAC,SAAiB,EAAE,SAAyB,EAAc,EAAE;;QAC3E,MAAM,UAAU,GAAqB,MAAM,CAAC,+BAAkB,CAAC,CAAC,IAAI,CAAC,CAAC,EAAC,QAAQ,EAAC,EAAE,EAAE,CAAC,QAAQ,KAAK,SAAS,CAAC,CAAC;QAC7G,OAAO,IAAI,UAAU,CAAC,MAAA,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAE,SAAS,mCAAI,SAAS,EAAE,SAAS,CAAC,CAAC;IACvE,CAAC,CAAC;IAEF,MAAM,GAAG,GAAG,CAAC,GAAG,IAAoB,EAAa,EAAE,CAAC,IAAI,SAAS,CAAC,GAAG,IAAI,CAAC,CAAC;IAC3E,MAAM,EAAE,GAAG,CAAC,GAAG,IAAoB,EAAY,EAAE,CAAC,IAAI,QAAQ,CAAC,GAAG,IAAI,CAAC,CAAC;IAExE,OAAO,EAAC,MAAM,EAAE,OAAO,EAAE,GAAG,EAAE,EAAE,EAAC,CAAC;AACpC,CAAC,CAAA;AAfY,QAAA,KAAK,SAejB"}
@@ -0,0 +1 @@
1
+ export * from './query-builder';
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ tslib_1.__exportStar(require("./query-builder"), exports);
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../packages/@nx-ddd/notion/src/lib/query-builder/index.ts"],"names":[],"mappings":";;;AAAA,0DAAgC"}
@@ -0,0 +1,27 @@
1
+ import { NotionBaseQuery } from "../query";
2
+ export declare class NotionQueryBuilder {
3
+ constructor();
4
+ build(filterQuery?: NotionBaseQuery, sortQuery?: NotionBaseQuery): {
5
+ sorts: any[];
6
+ filter: any;
7
+ } | {
8
+ sorts?: undefined;
9
+ filter: any;
10
+ } | {
11
+ sorts: any[];
12
+ filter?: undefined;
13
+ } | {
14
+ sorts?: undefined;
15
+ filter?: undefined;
16
+ };
17
+ protected buildSortQuery(query: NotionBaseQuery): {
18
+ sorts: any[];
19
+ } | {
20
+ sorts?: undefined;
21
+ };
22
+ protected buildFilterQuery(query: NotionBaseQuery): {
23
+ filter: any;
24
+ } | {
25
+ filter?: undefined;
26
+ };
27
+ }
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.NotionQueryBuilder = void 0;
4
+ class NotionQueryBuilder {
5
+ constructor() { }
6
+ build(filterQuery, sortQuery) {
7
+ return Object.assign(Object.assign({}, (filterQuery ? this.buildFilterQuery(filterQuery) : {})), (sortQuery ? this.buildSortQuery(sortQuery) : {}));
8
+ }
9
+ buildSortQuery(query) {
10
+ if (query.type === 'sort') {
11
+ return { sorts: [query.build()] };
12
+ }
13
+ else {
14
+ return {};
15
+ }
16
+ }
17
+ buildFilterQuery(query) {
18
+ if (query.type === 'filter') {
19
+ return { filter: { and: [query.build()] } };
20
+ }
21
+ else if (['and', 'or'].includes(query.type)) {
22
+ return { filter: query.build() };
23
+ }
24
+ else {
25
+ return {};
26
+ }
27
+ }
28
+ }
29
+ exports.NotionQueryBuilder = NotionQueryBuilder;
30
+ //# sourceMappingURL=query-builder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"query-builder.js","sourceRoot":"","sources":["../../../../../packages/@nx-ddd/notion/src/lib/query-builder/query-builder.ts"],"names":[],"mappings":";;;AAEA,MAAa,kBAAkB;IAC7B,gBAAgB,CAAC;IAEjB,KAAK,CAAC,WAA6B,EAAE,SAA2B;QAC9D,uCACK,CAAC,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC,gBAAgB,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,GACvD,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,cAAc,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,EACrD;IACH,CAAC;IAES,cAAc,CAAC,KAAsB;QAC7C,IAAI,KAAK,CAAC,IAAI,KAAK,MAAM,EAAE;YACzB,OAAO,EAAE,KAAK,EAAE,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC,EAAC,CAAC;SAClC;aAAM;YACL,OAAO,EAAE,CAAC;SACX;IACH,CAAC;IAES,gBAAgB,CAAC,KAAsB;QAC/C,IAAI,KAAK,CAAC,IAAI,KAAK,QAAQ,EAAE;YAC3B,OAAO,EAAE,MAAM,EAAE,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC,EAAE,EAAE,CAAC;SAC7C;aAAM,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE;YAC7C,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,KAAK,EAAE,EAAE,CAAC;SAClC;aAAM;YACL,OAAO,EAAE,CAAC;SACX;IACH,CAAC;CACF;AA3BD,gDA2BC"}
@@ -0,0 +1 @@
1
+ export * from './repository';
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ tslib_1.__exportStar(require("./repository"), exports);
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../packages/@nx-ddd/notion/src/lib/repository/index.ts"],"names":[],"mappings":";;;AAAA,uDAA6B"}
@@ -0,0 +1,31 @@
1
+ import { Client } from '@notionhq/client';
2
+ import { Entity } from '@nx-ddd/common/domain/models';
3
+ import { Repository } from '@nx-ddd/common/domain/repository';
4
+ import { InjectionToken } from '@nx-ddd/core/di';
5
+ import { NotionConverter } from '../converter';
6
+ import { NotionBaseQuery } from '../query';
7
+ import { NotionQueryBuilder } from '../query-builder';
8
+ export declare const NOTION_ACCESS_TOKEN: InjectionToken<unknown>;
9
+ export declare const NOTION_DATABASE_ID: InjectionToken<unknown>;
10
+ export declare abstract class NotionRepository<E extends Entity> extends Repository<E> {
11
+ protected token: string;
12
+ protected abstract databaseId: string;
13
+ protected abstract converter: NotionConverter<E>;
14
+ protected client: Client;
15
+ protected queryBuilder: NotionQueryBuilder;
16
+ protected get parent(): {
17
+ type: 'database_id';
18
+ database_id: string;
19
+ };
20
+ constructor(token: string);
21
+ protected query(filterQuery?: NotionBaseQuery, sortQuery?: NotionBaseQuery): Promise<E[]>;
22
+ list(): Promise<E[]>;
23
+ get({ id }: {
24
+ id: string;
25
+ }): Promise<E>;
26
+ create(entity: Partial<E>): Promise<E>;
27
+ update(entity: Partial<E>): Promise<void>;
28
+ delete({ id }: {
29
+ id: string;
30
+ }): Promise<void>;
31
+ }
@@ -0,0 +1,79 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.NotionRepository = exports.NOTION_DATABASE_ID = exports.NOTION_ACCESS_TOKEN = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const client_1 = require("@notionhq/client");
6
+ const repository_1 = require("@nx-ddd/common/domain/repository");
7
+ const di_1 = require("@nx-ddd/core/di");
8
+ const query_builder_1 = require("../query-builder");
9
+ exports.NOTION_ACCESS_TOKEN = new di_1.InjectionToken('[@nx-ddd/notion] Notion Access Token');
10
+ exports.NOTION_DATABASE_ID = new di_1.InjectionToken('[@nx-ddd/notion] Notion Database Id');
11
+ let NotionRepository = class NotionRepository extends repository_1.Repository {
12
+ constructor(token) {
13
+ super();
14
+ this.token = token;
15
+ this.client = new client_1.Client({ auth: this.token });
16
+ this.queryBuilder = new query_builder_1.NotionQueryBuilder();
17
+ }
18
+ get parent() {
19
+ return { type: 'database_id', database_id: this.databaseId };
20
+ }
21
+ query(filterQuery, sortQuery) {
22
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
23
+ try {
24
+ const obj = this.queryBuilder.build(filterQuery, sortQuery);
25
+ const { results } = yield this.client.databases.query(Object.assign({ database_id: this.databaseId }, obj));
26
+ return results.map(result => this.converter.fromRecord(result));
27
+ }
28
+ catch (error) {
29
+ throw error;
30
+ }
31
+ });
32
+ }
33
+ list() {
34
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
35
+ return this.query();
36
+ });
37
+ }
38
+ get({ id }) {
39
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
40
+ const data = yield this.client.pages.retrieve({ page_id: id });
41
+ return this.converter.fromRecord(data);
42
+ });
43
+ }
44
+ create(entity) {
45
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
46
+ try {
47
+ const res = yield this.client.pages.create({
48
+ parent: this.parent,
49
+ properties: Object.assign({}, this.converter.toRecord(entity)),
50
+ });
51
+ return this.converter.fromRecord(res);
52
+ }
53
+ catch (error) {
54
+ throw error;
55
+ }
56
+ });
57
+ }
58
+ update(entity) {
59
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
60
+ const data = {
61
+ page_id: entity.id,
62
+ properties: Object.assign({}, this.converter.toRecord(entity)),
63
+ };
64
+ yield this.client.pages.update(data);
65
+ });
66
+ }
67
+ delete({ id }) {
68
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
69
+ throw new Error('NotionRepository.delete() is not implemented');
70
+ });
71
+ }
72
+ };
73
+ NotionRepository = tslib_1.__decorate([
74
+ (0, di_1.Injectable)(),
75
+ tslib_1.__param(0, (0, di_1.Inject)(exports.NOTION_ACCESS_TOKEN)),
76
+ tslib_1.__metadata("design:paramtypes", [String])
77
+ ], NotionRepository);
78
+ exports.NotionRepository = NotionRepository;
79
+ //# sourceMappingURL=repository.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"repository.js","sourceRoot":"","sources":["../../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are type NotionText = {
4
+ type: 'text';
5
+ text: {
6
+ content: string;
7
+ };
8
+ plain_text: string;
9
+ };
10
+ declare type NotionArray = {
11
+ type: 'array';
12
+ array: (NotionRichText[] | NotionNumber[]);
13
+ function: 'show_original';
14
+ };
15
+ export declare type NotionTitle = {
16
+ type: 'title';
17
+ title: {
18
+ text: {
19
+ content: string;
20
+ };
21
+ }[];
22
+ };
23
+ export declare type NotionUrl = {
24
+ id: string;
25
+ type: 'url';
26
+ url: string | null;
27
+ };
28
+ export declare type NotionRichText = {
29
+ id: string;
30
+ type: 'rich_text';
31
+ rich_text: NotionText[];
32
+ };
33
+ export declare type NotionNumber = {
34
+ id: string;
35
+ type: 'number';
36
+ number: number;
37
+ };
38
+ export declare type NotionRelation = {
39
+ id: string;
40
+ type: 'relation';
41
+ relation: {
42
+ id: string;
43
+ }[];
44
+ has_more: boolean;
45
+ };
46
+ export declare type NotionStatus = {
47
+ id: string;
48
+ type: 'status';
49
+ status: {
50
+ id: string;
51
+ name: string;
52
+ color: string;
53
+ };
54
+ };
55
+ export declare type NotionFormula = {
56
+ id: string;
57
+ type: 'formula';
58
+ formula: {
59
+ type: 'string';
60
+ string: string;
61
+ } | {
62
+ type: 'number';
63
+ number: number;
64
+ };
65
+ };
66
+ export declare type NotionRollup = {
67
+ id: string;
68
+ type: 'rollup';
69
+ rollup: NotionArray;
70
+ };
71
+ export declare type NotionCreatedTime = {
72
+ id: string;
73
+ type: 'created_time';
74
+ created_time: string;
75
+ };
76
+ export declare type NotionLastEditedTime = {
77
+ id: string;
78
+ type: 'last_edited_time';
79
+ last_edited_time: string;
80
+ };
81
+ export declare type NotionDate = {
82
+ id: string;
83
+ type: 'date';
84
+ date: any;
85
+ };
86
+ export declare type NotionSelect = {
87
+ id: string;
88
+ type: 'select';
89
+ select: {
90
+ id: string;
91
+ name: string;
92
+ color: string;
93
+ };
94
+ };
95
+ export declare type NotionValue = NotionTitle | NotionUrl | NotionRichText | NotionNumber | NotionRelation | NotionStatus | NotionFormula | NotionRollup | NotionCreatedTime | NotionLastEditedTime | NotionDate | NotionSelect;
96
+ export declare class NotionUtils {
97
+ static toNotionValue(value: any, type: NotionFieldType): void | {
98
+ type: string;
99
+ title: {
100
+ text: {
101
+ content: string;
102
+ };
103
+ }[];
104
+ } | {
105
+ type: string;
106
+ status: {
107
+ name: string;
108
+ };
109
+ } | {
110
+ type: string;
111
+ relation: {
112
+ id: string;
113
+ }[];
114
+ } | {
115
+ type: string;
116
+ rich_text: {
117
+ text: {
118
+ content: string;
119
+ };
120
+ }[];
121
+ } | {
122
+ type: string;
123
+ url: string;
124
+ } | {
125
+ type: string;
126
+ date: {
127
+ start: string;
128
+ };
129
+ } | {
130
+ type: string;
131
+ select: {
132
+ name: string;
133
+ };
134
+ };
135
+ static toNotionTitle(value: string): {
136
+ type: string;
137
+ title: {
138
+ text: {
139
+ content: string;
140
+ };
141
+ }[];
142
+ };
143
+ static toNotionStatus(value: string): {
144
+ type: string;
145
+ status: {
146
+ name: string;
147
+ };
148
+ };
149
+ static toRelation(ids: string[]): {
150
+ type: string;
151
+ relation: {
152
+ id: string;
153
+ }[];
154
+ };
155
+ static toRichText(text?: string): {
156
+ type: string;
157
+ rich_text: {
158
+ text: {
159
+ content: string;
160
+ };
161
+ }[];
162
+ };
163
+ static toNotionFormula(value: string): void;
164
+ static toRollup(value: string): void;
165
+ static toUrl(value: string): {
166
+ type: string;
167
+ url: string;
168
+ };
169
+ static toDate(value: dayjs.Dayjs): {
170
+ type: string;
171
+ date: {
172
+ start: string;
173
+ };
174
+ };
175
+ static toSelect(value: string): {
176
+ type: string;
177
+ select: {
178
+ name: string;
179
+ };
180
+ };
181
+ static fromNotionValue(value: NotionValue): string | number | string[] | dayjs.Dayjs | number[];
182
+ static fromTitle(notionTitle: NotionTitle): string;
183
+ static fromUrl(notionUrl: NotionUrl): string | null;
184
+ static fromRichText(notionRichText: NotionRichText): string | null;
185
+ static fromRelation(notionRelation: NotionRelation): string[];
186
+ static fromStatus(notionStatus: NotionStatus): string;
187
+ static fromFormula(notionFormula: NotionFormula): string | number;
188
+ static fromRollup(notionRollup: NotionRollup): string[] | number[];
189
+ static fromCreatedTime(notionCreatedTime: NotionCreatedTime): dayjs.Dayjs;
190
+ static fromLastEditedTime(notionLastEditedTime: NotionLastEditedTime): dayjs.Dayjs;
191
+ static fromDate(notionDate: NotionDate): dayjs.Dayjs | null;
192
+ static fromNumber(notionNumber: NotionNumber): number;
193
+ static fromSelect(notionSelect: NotionSelect): string;
194
+ }
195
+ export {};
package/utils.js ADDED
@@ -0,0 +1,121 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.NotionUtils = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const dayjs_1 = tslib_1.__importDefault(require("dayjs"));
6
+ class NotionUtils {
7
+ static toNotionValue(value, type) {
8
+ switch (type) {
9
+ case 'title': return NotionUtils.toNotionTitle(value);
10
+ case 'status': return NotionUtils.toNotionStatus(value);
11
+ case 'relation': return NotionUtils.toRelation(value);
12
+ case 'formula': return NotionUtils.toNotionFormula(value);
13
+ case 'rich_text': return NotionUtils.toRichText(value);
14
+ case 'rollup': return NotionUtils.toRollup(value);
15
+ case 'url': return NotionUtils.toUrl(value);
16
+ case 'date': return NotionUtils.toDate(value);
17
+ case 'select': return NotionUtils.toSelect(value);
18
+ // case 'number': return NotionUtils.toNumber(value);
19
+ }
20
+ }
21
+ static toNotionTitle(value) {
22
+ return value ? { type: 'title', title: [{ text: { content: value } }] } : undefined;
23
+ }
24
+ static toNotionStatus(value) {
25
+ return value ? { type: 'status', status: { name: value } } : undefined;
26
+ }
27
+ static toRelation(ids) {
28
+ console.log('ids', ids);
29
+ return Array.isArray(ids) ? { type: 'relation', relation: (ids).map(id => ({ id })) } : undefined;
30
+ }
31
+ static toRichText(text) {
32
+ return text ? { type: 'rich_text', rich_text: [{ text: { content: text } }] } : undefined;
33
+ }
34
+ static toNotionFormula(value) {
35
+ return;
36
+ }
37
+ static toRollup(value) {
38
+ return;
39
+ }
40
+ static toUrl(value) {
41
+ return value ? { type: 'url', url: value } : undefined;
42
+ }
43
+ static toDate(value) {
44
+ // TODO(nontangent): endも考慮する。
45
+ return value ? { type: 'date', date: { start: value.format() } } : undefined;
46
+ }
47
+ static toSelect(value) {
48
+ return value ? { type: 'select', select: { name: value } } : undefined;
49
+ }
50
+ static fromNotionValue(value) {
51
+ switch (value.type) {
52
+ case 'title': return this.fromTitle(value);
53
+ case 'formula': return this.fromFormula(value);
54
+ case 'relation': return this.fromRelation(value);
55
+ case 'rich_text': return this.fromRichText(value);
56
+ case 'status': return this.fromStatus(value);
57
+ case 'url': return this.fromUrl(value);
58
+ case 'rollup': return this.fromRollup(value);
59
+ case 'created_time': return this.fromCreatedTime(value);
60
+ case 'last_edited_time': return this.fromLastEditedTime(value);
61
+ case 'date': return this.fromDate(value);
62
+ case 'number': return this.fromNumber(value);
63
+ case 'select': return NotionUtils.fromSelect(value);
64
+ }
65
+ }
66
+ static fromTitle(notionTitle) {
67
+ var _a, _b, _c, _d;
68
+ return (_d = (_c = (_b = (_a = notionTitle === null || notionTitle === void 0 ? void 0 : notionTitle.title) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.text) === null || _c === void 0 ? void 0 : _c.content) !== null && _d !== void 0 ? _d : '';
69
+ }
70
+ static fromUrl(notionUrl) {
71
+ return notionUrl.url;
72
+ }
73
+ static fromRichText(notionRichText) {
74
+ return notionRichText.rich_text.map(({ plain_text }) => plain_text).join('') || null;
75
+ }
76
+ static fromRelation(notionRelation) {
77
+ return notionRelation.relation.map(r => r.id);
78
+ }
79
+ static fromStatus(notionStatus) {
80
+ return notionStatus.status.name;
81
+ }
82
+ static fromFormula(notionFormula) {
83
+ var _a, _b, _c;
84
+ return ((_a = notionFormula.formula) === null || _a === void 0 ? void 0 : _a.type) === 'string'
85
+ ? (_b = notionFormula.formula) === null || _b === void 0 ? void 0 : _b.string
86
+ : (_c = notionFormula.formula) === null || _c === void 0 ? void 0 : _c.number;
87
+ }
88
+ static fromRollup(notionRollup) {
89
+ var _a;
90
+ return ((_a = notionRollup.rollup.array) !== null && _a !== void 0 ? _a : []).map(notionValue => {
91
+ var _a, _b;
92
+ if (notionValue.type === 'rich_text') {
93
+ return ((_a = notionValue.rich_text) !== null && _a !== void 0 ? _a : []).map(text => text.plain_text).join();
94
+ }
95
+ else if (notionValue.type === 'number') {
96
+ return (_b = notionValue.number) !== null && _b !== void 0 ? _b : null;
97
+ }
98
+ return [];
99
+ });
100
+ }
101
+ static fromCreatedTime(notionCreatedTime) {
102
+ return (0, dayjs_1.default)(notionCreatedTime.created_time);
103
+ }
104
+ static fromLastEditedTime(notionLastEditedTime) {
105
+ return (0, dayjs_1.default)(notionLastEditedTime.last_edited_time);
106
+ }
107
+ static fromDate(notionDate) {
108
+ var _a, _b;
109
+ return ((_a = notionDate.date) === null || _a === void 0 ? void 0 : _a.start) ? (0, dayjs_1.default)((_b = notionDate.date) === null || _b === void 0 ? void 0 : _b.start) : null;
110
+ }
111
+ static fromNumber(notionNumber) {
112
+ var _a;
113
+ return (_a = notionNumber.number) !== null && _a !== void 0 ? _a : null;
114
+ }
115
+ static fromSelect(notionSelect) {
116
+ var _a, _b;
117
+ return (_b = (_a = notionSelect.select) === null || _a === void 0 ? void 0 : _a.name) !== null && _b !== void 0 ? _b : null;
118
+ }
119
+ }
120
+ exports.NotionUtils = NotionUtils;
121
+ //# sourceMappingURL=utils.js.map
package/utils.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../../packages/@nx-ddd/notion/src/lib/utils.ts"],"names":[],"mappings":";;;;AAAA,0DAA0B;AAqC1B,MAAa,WAAW;IACtB,MAAM,CAAC,aAAa,CAAC,KAAU,EAAE,IAAqB;QACpD,QAAO,IAAI,EAAE;YACX,KAAK,OAAO,CAAC,CAAC,OAAO,WAAW,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;YACtD,KAAK,Q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