newt-client-js 3.3.0 → 3.3.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
@@ -59,6 +59,7 @@ client
59
59
  Please refer to the following documents.
60
60
 
61
61
  - [ガイド: SDK](https://www.newt.so/docs/js-sdk)
62
+ - [ガイド: 利用可能なクエリ](https://www.newt.so/docs/cdn-api-newt-api-queries)
62
63
  - [チュートリアル: NewtのAPIで利用できるクエリパラメータを理解して、様々なクエリを実行する](https://www.newt.so/docs/tutorials/understanding-query-parameters)
63
64
  - [REST API reference](https://developers.newt.so/)
64
65
 
@@ -1,7 +1,7 @@
1
- import { CreateClientParams, GetContentsParams, GetContentParams, GetFirstContentParams, Contents, GetAppParams, AppMeta } from './types';
2
- export declare const createClient: ({ spaceUid, token, apiType, adapter, retryOnError, retryLimit, fetch, }: CreateClientParams) => {
3
- getContents: <T>({ appUid, modelUid, query, }: GetContentsParams) => Promise<Contents<T>>;
4
- getContent: <T_1>({ appUid, modelUid, contentId, query, }: GetContentParams) => Promise<T_1>;
5
- getFirstContent: <T_2>({ appUid, modelUid, query, }: GetFirstContentParams) => Promise<T_2 | null>;
6
- getApp: ({ appUid }: GetAppParams) => Promise<AppMeta>;
7
- };
1
+ import { CreateClientParams, GetContentsParams, GetContentParams, GetFirstContentParams, Contents, GetAppParams, AppMeta } from './types';
2
+ export declare const createClient: ({ spaceUid, token, apiType, adapter, retryOnError, retryLimit, fetch, }: CreateClientParams) => {
3
+ getContents: <T>({ appUid, modelUid, query, }: GetContentsParams) => Promise<Contents<T>>;
4
+ getContent: <T_1>({ appUid, modelUid, contentId, query, }: GetContentParams) => Promise<T_1>;
5
+ getFirstContent: <T_2>({ appUid, modelUid, query, }: GetFirstContentParams) => Promise<T_2 | null>;
6
+ getApp: ({ appUid }: GetAppParams) => Promise<AppMeta>;
7
+ };
@@ -1,3 +1,3 @@
1
- import type { ErrorRequest } from './types';
2
- export declare const axiosErrorHandler: (errorResponse: unknown) => never;
3
- export declare const fetchErrorHandler: (errorResponse: unknown, errorRequest: ErrorRequest) => never;
1
+ import type { ErrorRequest } from './types';
2
+ export declare const axiosErrorHandler: (errorResponse: unknown) => never;
3
+ export declare const fetchErrorHandler: (errorResponse: unknown, errorRequest: ErrorRequest) => never;
@@ -1,2 +1,2 @@
1
- export { createClient } from './createClient';
2
- export { CreateClientParams, Client, GetContentsParams, GetContentParams, GetFirstContentParams, GetContentsQuery, GetContentQuery, GetFirstContentQuery, Contents, Content, Image, File, Media, AppMeta, AppCover, AppIcon, GetAppParams, NewtError, ErrorRequest, ErrorResponse, } from './types';
1
+ export { createClient } from './createClient';
2
+ export { CreateClientParams, Client, GetContentsParams, GetContentParams, GetFirstContentParams, GetContentsQuery, GetContentQuery, GetFirstContentQuery, Contents, Content, Image, File, Media, AppMeta, AppCover, AppIcon, GetAppParams, NewtError, ErrorRequest, ErrorResponse, } from './types';
@@ -1,163 +1,163 @@
1
- import { AxiosAdapter } from 'axios';
2
- export interface CreateClientParams {
3
- spaceUid: string;
4
- token: string;
5
- apiType?: 'cdn' | 'api';
6
- adapter?: AxiosAdapter;
7
- retryOnError?: boolean;
8
- retryLimit?: number;
9
- fetch?: typeof fetch;
10
- }
11
- export interface Client {
12
- getContents: <T>(params: GetContentsParams) => Promise<Contents<T>>;
13
- getContent: <T>(params: GetContentParams) => Promise<T>;
14
- getFirstContent: <T>(params: GetFirstContentParams) => Promise<T | null>;
15
- getApp: (params: GetAppParams) => Promise<AppMeta>;
16
- }
17
- export interface GetContentsParams {
18
- appUid: string;
19
- modelUid: string;
20
- query?: GetContentsQuery;
21
- }
22
- export interface GetContentParams {
23
- appUid: string;
24
- modelUid: string;
25
- contentId: string;
26
- query?: GetContentQuery;
27
- }
28
- export interface GetFirstContentParams {
29
- appUid: string;
30
- modelUid: string;
31
- query?: GetFirstContentQuery;
32
- }
33
- declare type OperatorValue = {
34
- ne?: string | number | boolean;
35
- match?: string;
36
- in?: string[] | number[];
37
- nin?: string[] | number[];
38
- all?: string[] | number[];
39
- exists?: boolean;
40
- lt?: string | number;
41
- lte?: string | number;
42
- gt?: string | number;
43
- gte?: string | number;
44
- fmt?: 'text';
45
- };
46
- declare type QueryValue = string | number | boolean | OperatorValue;
47
- export declare type FilterQuery = {
48
- or?: Array<FilterQuery>;
49
- and?: Array<FilterQuery>;
50
- [key: string]: QueryValue | Array<FilterQuery> | undefined;
51
- };
52
- export declare type Query = {
53
- select?: string[];
54
- order?: string[];
55
- limit?: number;
56
- skip?: number;
57
- depth?: number;
58
- or?: Array<FilterQuery>;
59
- and?: Array<FilterQuery>;
60
- [key: string]: QueryValue | string[] | Array<FilterQuery> | undefined;
61
- };
62
- export declare type GetContentsQuery = Query;
63
- declare type ExceptFormat = {
64
- select?: string[];
65
- depth?: number;
66
- };
67
- declare type Format = {
68
- [key: string]: {
69
- fmt: 'text';
70
- };
71
- };
72
- export declare type GetContentQuery = ExceptFormat | Format;
73
- export declare type GetFirstContentQuery = Omit<Query, 'limit'>;
74
- export interface Contents<T> {
75
- skip: number;
76
- limit: number;
77
- total: number;
78
- items: Array<T>;
79
- }
80
- export interface Content {
81
- _id: string;
82
- _sys: {
83
- createdAt: string;
84
- updatedAt: string;
85
- customOrder: number;
86
- raw: {
87
- createdAt: string;
88
- updatedAt: string;
89
- firstPublishedAt: string;
90
- publishedAt: string;
91
- };
92
- };
93
- }
94
- export interface Image {
95
- _id: string;
96
- src: string;
97
- fileName: string;
98
- fileType: string;
99
- fileSize: number;
100
- width: number;
101
- height: number;
102
- title: string;
103
- description: string;
104
- altText: string;
105
- metadata: Record<string, string | number | boolean>;
106
- }
107
- export interface File {
108
- _id: string;
109
- src: string;
110
- fileName: string;
111
- fileType: string;
112
- fileSize: number;
113
- width: number | null;
114
- height: number | null;
115
- title: string;
116
- description: string;
117
- altText: string;
118
- metadata: Record<string, string | number | boolean>;
119
- }
120
- export interface Media {
121
- _id: string;
122
- src: string;
123
- fileName: string;
124
- fileType: string;
125
- fileSize: number;
126
- width: number | null;
127
- height: number | null;
128
- title: string;
129
- description: string;
130
- altText: string;
131
- metadata: Record<string, string | number | boolean>;
132
- }
133
- export declare type AppIcon = {
134
- type: string;
135
- value: string;
136
- };
137
- export declare type AppCover = {
138
- type: string;
139
- value: string;
140
- };
141
- export interface AppMeta {
142
- name: string;
143
- uid: string;
144
- icon?: AppIcon;
145
- cover?: AppCover;
146
- }
147
- export interface GetAppParams {
148
- appUid: string;
149
- }
150
- export interface NewtError {
151
- status: number;
152
- code: string;
153
- message: string;
154
- }
155
- export interface ErrorRequest {
156
- method?: string;
157
- headers?: Record<string, string>;
158
- url?: string;
159
- }
160
- export interface ErrorResponse extends NewtError {
161
- request?: ErrorRequest;
162
- }
163
- export {};
1
+ import { AxiosAdapter } from 'axios';
2
+ export interface CreateClientParams {
3
+ spaceUid: string;
4
+ token: string;
5
+ apiType?: 'cdn' | 'api';
6
+ adapter?: AxiosAdapter;
7
+ retryOnError?: boolean;
8
+ retryLimit?: number;
9
+ fetch?: typeof fetch;
10
+ }
11
+ export interface Client {
12
+ getContents: <T>(params: GetContentsParams) => Promise<Contents<T>>;
13
+ getContent: <T>(params: GetContentParams) => Promise<T>;
14
+ getFirstContent: <T>(params: GetFirstContentParams) => Promise<T | null>;
15
+ getApp: (params: GetAppParams) => Promise<AppMeta>;
16
+ }
17
+ export interface GetContentsParams {
18
+ appUid: string;
19
+ modelUid: string;
20
+ query?: GetContentsQuery;
21
+ }
22
+ export interface GetContentParams {
23
+ appUid: string;
24
+ modelUid: string;
25
+ contentId: string;
26
+ query?: GetContentQuery;
27
+ }
28
+ export interface GetFirstContentParams {
29
+ appUid: string;
30
+ modelUid: string;
31
+ query?: GetFirstContentQuery;
32
+ }
33
+ type OperatorValue = {
34
+ ne?: string | number | boolean;
35
+ match?: string;
36
+ in?: string[] | number[];
37
+ nin?: string[] | number[];
38
+ all?: string[] | number[];
39
+ exists?: boolean;
40
+ lt?: string | number;
41
+ lte?: string | number;
42
+ gt?: string | number;
43
+ gte?: string | number;
44
+ fmt?: 'text';
45
+ };
46
+ type QueryValue = string | number | boolean | OperatorValue;
47
+ export type FilterQuery = {
48
+ or?: Array<FilterQuery>;
49
+ and?: Array<FilterQuery>;
50
+ [key: string]: QueryValue | Array<FilterQuery> | undefined;
51
+ };
52
+ export type Query = {
53
+ select?: string[];
54
+ order?: string[];
55
+ limit?: number;
56
+ skip?: number;
57
+ depth?: number;
58
+ or?: Array<FilterQuery>;
59
+ and?: Array<FilterQuery>;
60
+ [key: string]: QueryValue | string[] | Array<FilterQuery> | undefined;
61
+ };
62
+ export type GetContentsQuery = Query;
63
+ type ExceptFormat = {
64
+ select?: string[];
65
+ depth?: number;
66
+ };
67
+ type Format = {
68
+ [key: string]: {
69
+ fmt: 'text';
70
+ };
71
+ };
72
+ export type GetContentQuery = ExceptFormat | Format;
73
+ export type GetFirstContentQuery = Omit<Query, 'limit'>;
74
+ export interface Contents<T> {
75
+ skip: number;
76
+ limit: number;
77
+ total: number;
78
+ items: Array<T>;
79
+ }
80
+ export interface Content {
81
+ _id: string;
82
+ _sys: {
83
+ createdAt: string;
84
+ updatedAt: string;
85
+ customOrder: number;
86
+ raw: {
87
+ createdAt: string;
88
+ updatedAt: string;
89
+ firstPublishedAt: string;
90
+ publishedAt: string;
91
+ };
92
+ };
93
+ }
94
+ export interface Image {
95
+ _id: string;
96
+ src: string;
97
+ fileName: string;
98
+ fileType: string;
99
+ fileSize: number;
100
+ width: number;
101
+ height: number;
102
+ title: string;
103
+ description: string;
104
+ altText: string;
105
+ metadata: Record<string, string | number | boolean>;
106
+ }
107
+ export interface File {
108
+ _id: string;
109
+ src: string;
110
+ fileName: string;
111
+ fileType: string;
112
+ fileSize: number;
113
+ width: number | null;
114
+ height: number | null;
115
+ title: string;
116
+ description: string;
117
+ altText: string;
118
+ metadata: Record<string, string | number | boolean>;
119
+ }
120
+ export interface Media {
121
+ _id: string;
122
+ src: string;
123
+ fileName: string;
124
+ fileType: string;
125
+ fileSize: number;
126
+ width: number | null;
127
+ height: number | null;
128
+ title: string;
129
+ description: string;
130
+ altText: string;
131
+ metadata: Record<string, string | number | boolean>;
132
+ }
133
+ export type AppIcon = {
134
+ type: string;
135
+ value: string;
136
+ };
137
+ export type AppCover = {
138
+ type: string;
139
+ value: string;
140
+ };
141
+ export interface AppMeta {
142
+ name: string;
143
+ uid: string;
144
+ icon?: AppIcon;
145
+ cover?: AppCover;
146
+ }
147
+ export interface GetAppParams {
148
+ appUid: string;
149
+ }
150
+ export interface NewtError {
151
+ status: number;
152
+ code: string;
153
+ message: string;
154
+ }
155
+ export interface ErrorRequest {
156
+ method?: string;
157
+ headers?: Record<string, string>;
158
+ url?: string;
159
+ }
160
+ export interface ErrorResponse extends NewtError {
161
+ request?: ErrorRequest;
162
+ }
163
+ export {};
@@ -1,5 +1,5 @@
1
- import { Query } from '../types';
2
- export declare const parseQuery: (query: Query) => {
3
- raw: string;
4
- encoded: string;
5
- };
1
+ import { Query } from '../types';
2
+ export declare const parseQuery: (query: Query) => {
3
+ raw: string;
4
+ encoded: string;
5
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "newt-client-js",
3
- "version": "3.3.0",
3
+ "version": "3.3.2",
4
4
  "description": "JavaScript SDK for Newt's API",
5
5
  "main": "./dist/cjs/newtClient.js",
6
6
  "module": "./dist/esm/newtClient.js",
@@ -29,24 +29,8 @@
29
29
  "lint:prettier": "prettier --check ./src",
30
30
  "fix:eslint": "eslint --fix ./src",
31
31
  "fix:prettier": "prettier --write ./src",
32
- "test": "jest"
33
- },
34
- "jest": {
35
- "moduleFileExtensions": [
36
- "ts",
37
- "js"
38
- ],
39
- "transform": {
40
- "^.+\\.ts$": "ts-jest"
41
- },
42
- "globals": {
43
- "ts-jest": {
44
- "tsconfig": "tests/tsconfig.json"
45
- }
46
- },
47
- "testMatch": [
48
- "**/tests/**/*.test.ts"
49
- ]
32
+ "test": "jest",
33
+ "test:coverage": "jest --coverage=true"
50
34
  },
51
35
  "dependencies": {
52
36
  "axios": "^1.6.0",
@@ -59,21 +43,21 @@
59
43
  "@rollup/plugin-babel": "^5.3.0",
60
44
  "@rollup/plugin-commonjs": "^21.0.1",
61
45
  "@rollup/plugin-node-resolve": "^13.1.3",
62
- "@types/jest": "^27.0.3",
63
- "@types/node": "^16.7.8",
46
+ "@types/jest": "^29.5.11",
47
+ "@types/node": "20.12.7",
64
48
  "@types/qs": "^6.9.7",
65
- "@typescript-eslint/eslint-plugin": "^4.30.0",
66
- "@typescript-eslint/parser": "^4.30.0",
49
+ "@typescript-eslint/eslint-plugin": "^6.19.0",
50
+ "@typescript-eslint/parser": "^6.19.0",
67
51
  "eslint": "^7.32.0",
68
52
  "eslint-config-prettier": "^8.3.0",
69
- "jest": "^27.4.3",
53
+ "jest": "^29.7.0",
70
54
  "prettier": "^2.3.2",
71
55
  "rimraf": "^3.0.2",
72
56
  "rollup": "^2.67.1",
73
57
  "rollup-plugin-terser": "^7.0.2",
74
58
  "rollup-plugin-typescript2": "^0.31.2",
75
- "ts-jest": "^27.1.0",
59
+ "ts-jest": "^29.1.1",
76
60
  "tslib": "^2.3.1",
77
- "typescript": "^4.4.2"
61
+ "typescript": "^5.3.3"
78
62
  }
79
63
  }