@elumixor/notion-orm 2.1.0 → 2.1.2

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.
package/README.md CHANGED
@@ -44,9 +44,6 @@ Generates `generated/notion-orm/` with a typed client per database and an `index
44
44
  import { NotionORM } from "../generated/notion-orm";
45
45
 
46
46
  const notion = new NotionORM(process.env.NOTION_API_KEY);
47
-
48
- // or with a config object
49
- const notion = new NotionORM({ auth: process.env.NOTION_API_KEY });
50
47
  ```
51
48
 
52
49
  ## API
package/dist/cli.js CHANGED
@@ -174122,7 +174122,7 @@ function writeNotionORMFile(databasesDirPath, databasesMetadata) {
174122
174122
  fs3.mkdirSync(databasesDirPath, { recursive: true });
174123
174123
  if (databasesMetadata.length === 0) {
174124
174124
  writeWithJs(notionORMFile, `export class NotionORM {
174125
- constructor(_auth: string | { auth: string }) {}
174125
+ constructor(_auth: string) {}
174126
174126
  }
174127
174127
  `);
174128
174128
  return;
@@ -174131,14 +174131,14 @@ function writeNotionORMFile(databasesDirPath, databasesMetadata) {
174131
174131
  `);
174132
174132
  const properties = databasesMetadata.map(({ camelCaseName }) => ` public ${camelCaseName}: ReturnType<typeof ${camelCaseName}>;`).join(`
174133
174133
  `);
174134
- const assignments = databasesMetadata.map(({ camelCaseName }) => ` this.${camelCaseName} = ${camelCaseName}(typeof auth === "string" ? auth : auth.auth);`).join(`
174134
+ const assignments = databasesMetadata.map(({ camelCaseName }) => ` this.${camelCaseName} = ${camelCaseName}(auth);`).join(`
174135
174135
  `);
174136
174136
  const tsCode = `${imports}
174137
174137
 
174138
174138
  export class NotionORM {
174139
174139
  ${properties}
174140
174140
 
174141
- constructor(auth: string | { auth: string }) {
174141
+ constructor(auth: string) {
174142
174142
  ${assignments}
174143
174143
  }
174144
174144
  }
@@ -107,16 +107,16 @@ export declare class DatabaseClient<DatabaseSchemaType extends Record<string, an
107
107
  /** Create a new record and return it. */
108
108
  create(args: {
109
109
  data: DatabaseSchemaType;
110
- $icon?: string;
111
- $cover?: string;
110
+ $icon?: string | null;
111
+ $cover?: string | null;
112
112
  }): Promise<Partial<DatabaseSchemaType> & {
113
113
  id: string;
114
114
  }>;
115
115
  /** Create multiple records and return them. */
116
116
  createMany(args: {
117
117
  data: DatabaseSchemaType[];
118
- $icon?: string;
119
- $cover?: string;
118
+ $icon?: string | null;
119
+ $cover?: string | null;
120
120
  }): Promise<(Partial<DatabaseSchemaType> & {
121
121
  id: string;
122
122
  })[]>;
@@ -126,15 +126,15 @@ export declare class DatabaseClient<DatabaseSchemaType extends Record<string, an
126
126
  id: string;
127
127
  };
128
128
  data: Partial<DatabaseSchemaType>;
129
- $icon?: string;
130
- $cover?: string;
129
+ $icon?: string | null;
130
+ $cover?: string | null;
131
131
  }): Promise<void>;
132
132
  /** Update all records matching the filter. Returns the count of updated records. */
133
133
  updateMany(args: {
134
134
  where?: QueryFilter<DatabaseSchemaType, ColumnNameToColumnType>;
135
135
  data: Partial<DatabaseSchemaType>;
136
- $icon?: string;
137
- $cover?: string;
136
+ $icon?: string | null;
137
+ $cover?: string | null;
138
138
  }): Promise<{
139
139
  count: number;
140
140
  }>;
@@ -143,8 +143,8 @@ export declare class DatabaseClient<DatabaseSchemaType extends Record<string, an
143
143
  where: QueryFilter<DatabaseSchemaType, ColumnNameToColumnType>;
144
144
  create: DatabaseSchemaType;
145
145
  update: Partial<DatabaseSchemaType>;
146
- $icon?: string;
147
- $cover?: string;
146
+ $icon?: string | null;
147
+ $cover?: string | null;
148
148
  }): Promise<{
149
149
  created: boolean;
150
150
  id: string;
package/dist/index.js CHANGED
@@ -1686,9 +1686,9 @@ class DatabaseClient {
1686
1686
  async update(args) {
1687
1687
  const callBody = { page_id: args.where.id, properties: {} };
1688
1688
  if (args.$icon !== undefined)
1689
- callBody.icon = { type: "external", external: { url: args.$icon } };
1689
+ callBody.icon = args.$icon === null ? null : { type: "external", external: { url: args.$icon } };
1690
1690
  if (args.$cover !== undefined)
1691
- callBody.cover = { type: "external", external: { url: args.$cover } };
1691
+ callBody.cover = args.$cover === null ? null : { type: "external", external: { url: args.$cover } };
1692
1692
  for (const [propertyName, value] of Object.entries(args.data)) {
1693
1693
  const { type, columnName } = this.camelPropertyNameToNameAndTypeMap[propertyName];
1694
1694
  const columnObject = buildPropertyValueForAddPage({ type, value });
@@ -1733,10 +1733,10 @@ class DatabaseClient {
1733
1733
  parent: { data_source_id: this.id, type: "data_source_id" },
1734
1734
  properties: {}
1735
1735
  };
1736
- if ($icon)
1737
- callBody.icon = { type: "external", external: { url: $icon } };
1738
- if ($cover)
1739
- callBody.cover = { type: "external", external: { url: $cover } };
1736
+ if ($icon !== undefined)
1737
+ callBody.icon = $icon === null ? null : { type: "external", external: { url: $icon } };
1738
+ if ($cover !== undefined)
1739
+ callBody.cover = $cover === null ? null : { type: "external", external: { url: $cover } };
1740
1740
  for (const [propertyName, value] of Object.entries(data)) {
1741
1741
  const { type, columnName } = this.camelPropertyNameToNameAndTypeMap[propertyName];
1742
1742
  const columnObject = buildPropertyValueForAddPage({ type, value });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elumixor/notion-orm",
3
- "version": "2.1.0",
3
+ "version": "2.1.2",
4
4
  "type": "module",
5
5
  "description": "Bring Notion database schemas/types to TypeScript",
6
6
  "main": "dist/index.js",