@uidev1116/acms-js-sdk 0.1.1 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +256 -7
- package/dist/cjs/acms-js-sdk.cjs +3 -3
- package/dist/cjs/acms-path.cjs +4 -1
- package/dist/cjs/type-guard.cjs +1 -1
- package/dist/es/acms-js-sdk.js +56 -63
- package/dist/es/acms-path.js +2124 -4
- package/dist/es/type-guard.js +2 -3
- package/dist/index-BeSRDPIk.js +15 -0
- package/dist/index-Bm4C_vR2.cjs +1 -0
- package/dist/types/core/AcmsClient.d.ts +4 -4
- package/dist/types/core/AcmsFetchError.d.ts +1 -1
- package/dist/types/index.d.ts +1 -0
- package/dist/types/lib/acmsPath/acmsField.d.ts +13 -0
- package/dist/types/lib/acmsPath/acmsField.test.d.ts +1 -0
- package/dist/types/lib/acmsPath/acmsPath.d.ts +2 -2
- package/dist/types/lib/acmsPath/{defaultOptions.d.ts → defaults.d.ts} +1 -0
- package/dist/types/lib/acmsPath/index.d.ts +1 -0
- package/dist/types/lib/acmsPath/parseAcmsPath.d.ts +1 -1
- package/dist/types/lib/acmsPath/types.d.ts +32 -7
- package/dist/types/lib/acmsPath/utils.d.ts +1 -0
- package/dist/types/lib/acmsPath/utils.test.d.ts +1 -0
- package/dist/types/lib/typeGuard/isAcmsFetchError.d.ts +1 -1
- package/dist/types/types/index.d.ts +3 -3
- package/dist/types/utils/index.d.ts +3 -0
- package/dist/types/utils/mergeConfig.d.ts +10 -0
- package/dist/types/utils/mergeConfig.test.d.ts +1 -0
- package/dist/types/utils/parseFormData.d.ts +7 -0
- package/dist/types/utils/unique.d.ts +1 -0
- package/package.json +28 -27
- package/dist/browser-ponyfill-EPWIFhDK.js +0 -339
- package/dist/browser-ponyfill-r3mBr4hd.cjs +0 -2
- package/dist/index-H2fSgwjT.js +0 -328
- package/dist/index-WFlkDf6U.cjs +0 -1
- package/dist/index-ZZQxXurp.js +0 -19
- package/dist/index-x-5Zn68j.cjs +0 -1
- /package/dist/{typeGuard-eqTQ9U-x.cjs → typeGuard-B-hez9oi.cjs} +0 -0
- /package/dist/{typeGuard-Jsany_41.js → typeGuard-CkfEvQcm.js} +0 -0
package/dist/es/type-guard.js
CHANGED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { b as o } from "./typeGuard-CkfEvQcm.js";
|
|
2
|
+
class n extends Error {
|
|
3
|
+
code;
|
|
4
|
+
response;
|
|
5
|
+
constructor(s, e, t, c) {
|
|
6
|
+
super(s, c), this.name = "AcmsFetchError", this.code = e, this.response = t;
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
function h(r) {
|
|
10
|
+
return o(r) && r instanceof n;
|
|
11
|
+
}
|
|
12
|
+
export {
|
|
13
|
+
n as A,
|
|
14
|
+
h as i
|
|
15
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const n=require("./typeGuard-B-hez9oi.cjs");class s extends Error{code;response;constructor(e,c,t,o){super(e,o),this.name="AcmsFetchError",this.code=c,this.response=t}}function i(r){return n.isObject(r)&&r instanceof s}exports.AcmsFetchError=s;exports.isAcmsFetchError=i;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { AcmsClientOptions, AcmsClientConfig, AcmsResponse, URLComposable } from '../types';
|
|
2
|
+
import { default as AcmsFetchError } from './AcmsFetchError';
|
|
3
3
|
export default class AcmsClient {
|
|
4
4
|
private readonly baseUrl;
|
|
5
5
|
private readonly apiKey;
|
|
@@ -11,7 +11,7 @@ export default class AcmsClient {
|
|
|
11
11
|
private request;
|
|
12
12
|
private createFetchOptions;
|
|
13
13
|
private createUrl;
|
|
14
|
-
get<T = any>(
|
|
15
|
-
static isAcmsFetchError(payload: any):
|
|
14
|
+
get<T = any>(urlComposable: URLComposable, options?: AcmsClientOptions): Promise<AcmsResponse<T>>;
|
|
15
|
+
static isAcmsFetchError(payload: any): payload is AcmsFetchError<any>;
|
|
16
16
|
getConfig(): AcmsClientConfig;
|
|
17
17
|
}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export { default as createClient } from './createClient';
|
|
2
2
|
export { default as acmsPath } from './lib/acmsPath/acmsPath';
|
|
3
3
|
export { default as parseAcmsPath } from './lib/acmsPath/parseAcmsPath';
|
|
4
|
+
export { default as AcmsFieldList } from './lib/acmsPath/acmsField';
|
|
4
5
|
export * from './lib/typeGuard';
|
|
5
6
|
export type * from './types';
|
|
6
7
|
export type * from './lib/acmsPath/types';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { AcmsField } from './types';
|
|
2
|
+
export default class AcmsFieldList {
|
|
3
|
+
private readonly fields;
|
|
4
|
+
constructor(fields?: AcmsField[]);
|
|
5
|
+
push(field: AcmsField): void;
|
|
6
|
+
pop(): AcmsField | undefined;
|
|
7
|
+
shift(): AcmsField | undefined;
|
|
8
|
+
unshift(field: AcmsField): void;
|
|
9
|
+
getFields(): AcmsField[];
|
|
10
|
+
toString(): string;
|
|
11
|
+
static fromString(input: string): AcmsFieldList;
|
|
12
|
+
static fromFormData(formData: FormData): AcmsFieldList;
|
|
13
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
export default function acmsPath(paramsOrCtx: AcmsPathParams |
|
|
1
|
+
import { AcmsContextWithSearchParams, AcmsPathOptions, AcmsPathParams } from './types';
|
|
2
|
+
export default function acmsPath(paramsOrCtx: AcmsPathParams | AcmsContextWithSearchParams, options?: AcmsPathOptions): string;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { AcmsContext, ParseAcmsPathOptions } from './types';
|
|
2
2
|
export default function parseAcmsPath(path: string, options?: ParseAcmsPathOptions): AcmsContext;
|
|
@@ -1,10 +1,14 @@
|
|
|
1
|
+
import { RecursivePartial } from '../../types';
|
|
2
|
+
import { default as AcmsFieldList } from './acmsField';
|
|
3
|
+
export type ApiVersion = 'v1' | 'v2';
|
|
1
4
|
export interface AcmsPathParams {
|
|
2
5
|
blog?: string | number;
|
|
3
6
|
category?: string | string[] | number;
|
|
4
7
|
entry?: string | number;
|
|
5
8
|
user?: number;
|
|
9
|
+
unit?: string;
|
|
6
10
|
tag?: string[];
|
|
7
|
-
field?: string;
|
|
11
|
+
field?: string | AcmsFieldList;
|
|
8
12
|
span?: {
|
|
9
13
|
start?: string | Date;
|
|
10
14
|
end?: string | Date;
|
|
@@ -21,15 +25,16 @@ export interface AcmsPathParams {
|
|
|
21
25
|
admin?: string;
|
|
22
26
|
tpl?: string;
|
|
23
27
|
api?: string;
|
|
24
|
-
searchParams?:
|
|
28
|
+
searchParams?: Record<string, any>;
|
|
25
29
|
}
|
|
26
30
|
export interface AcmsContext {
|
|
27
31
|
bid?: number;
|
|
28
32
|
cid?: number;
|
|
29
33
|
eid?: number;
|
|
30
34
|
uid?: number;
|
|
35
|
+
utid?: string;
|
|
31
36
|
tag?: string[];
|
|
32
|
-
field?:
|
|
37
|
+
field?: AcmsFieldList;
|
|
33
38
|
span?: {
|
|
34
39
|
start: string | Date;
|
|
35
40
|
end: string | Date;
|
|
@@ -46,14 +51,19 @@ export interface AcmsContext {
|
|
|
46
51
|
admin?: string;
|
|
47
52
|
tpl?: string;
|
|
48
53
|
api?: string;
|
|
54
|
+
apiVersion?: ApiVersion;
|
|
49
55
|
unresolvedPath?: string;
|
|
50
56
|
}
|
|
57
|
+
export interface AcmsContextWithSearchParams extends AcmsContext {
|
|
58
|
+
searchParams?: Record<string, any> | URLSearchParams;
|
|
59
|
+
}
|
|
51
60
|
export interface AcmsPathSegments {
|
|
52
61
|
bid: string;
|
|
53
62
|
admin: string;
|
|
54
63
|
cid: string;
|
|
55
64
|
eid: string;
|
|
56
65
|
uid: string;
|
|
66
|
+
utid: string;
|
|
57
67
|
tag: string;
|
|
58
68
|
field: string;
|
|
59
69
|
span: string;
|
|
@@ -64,11 +74,9 @@ export interface AcmsPathSegments {
|
|
|
64
74
|
tpl: string;
|
|
65
75
|
api: string;
|
|
66
76
|
}
|
|
67
|
-
type RecursivePartial<T> = {
|
|
68
|
-
[P in keyof T]?: T[P] extends Array<infer U> ? Array<RecursivePartial<U>> : T[P] extends object ? RecursivePartial<T[P]> : T[P];
|
|
69
|
-
};
|
|
70
77
|
export interface AcmsPathConfig {
|
|
71
78
|
segments: AcmsPathSegments;
|
|
79
|
+
apiVersion?: ApiVersion;
|
|
72
80
|
}
|
|
73
81
|
export interface ParseAcmsPathConfig {
|
|
74
82
|
segments: AcmsPathSegments;
|
|
@@ -77,4 +85,21 @@ export interface AcmsPathOptions extends RecursivePartial<AcmsPathConfig> {
|
|
|
77
85
|
}
|
|
78
86
|
export interface ParseAcmsPathOptions extends RecursivePartial<ParseAcmsPathConfig> {
|
|
79
87
|
}
|
|
80
|
-
export
|
|
88
|
+
export type Connector = 'and' | 'or';
|
|
89
|
+
export declare function isConnector(value: any): value is Connector;
|
|
90
|
+
export type Operator = 'eq' | 'neq' | 'gt' | 'lt' | 'gte' | 'lte' | 'lk' | 'nlk' | 're' | 'nre' | 'em' | 'nem';
|
|
91
|
+
export declare function isOperator(value: any): value is Operator;
|
|
92
|
+
export type Separator = '_and_' | '_or_';
|
|
93
|
+
export declare function isSeparator(value: any): value is Separator;
|
|
94
|
+
export interface AcmsFilter {
|
|
95
|
+
operator: Operator;
|
|
96
|
+
value: string;
|
|
97
|
+
connector: Connector;
|
|
98
|
+
}
|
|
99
|
+
export declare function isAcmsFilter(value: any): value is AcmsFilter;
|
|
100
|
+
export interface AcmsField {
|
|
101
|
+
key: string;
|
|
102
|
+
filters: AcmsFilter[];
|
|
103
|
+
separator?: Separator;
|
|
104
|
+
}
|
|
105
|
+
export declare function isAcmsField(value: any): value is AcmsField;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AcmsPathOptions } from '../lib/acmsPath';
|
|
1
|
+
import { AcmsPathOptions, acmsPath } from '../lib/acmsPath';
|
|
2
2
|
export interface AcmsResponse<T> {
|
|
3
3
|
data: T;
|
|
4
4
|
status: number;
|
|
@@ -11,9 +11,9 @@ export interface AcmsClientConfig {
|
|
|
11
11
|
responseType: ResponseType;
|
|
12
12
|
acmsPathOptions?: AcmsPathOptions;
|
|
13
13
|
}
|
|
14
|
-
type RecursivePartial<T> = {
|
|
14
|
+
export type RecursivePartial<T> = {
|
|
15
15
|
[P in keyof T]?: T[P] extends Array<infer U> ? Array<RecursivePartial<U>> : T[P] extends object ? RecursivePartial<T[P]> : T[P];
|
|
16
16
|
};
|
|
17
17
|
export interface AcmsClientOptions extends RecursivePartial<AcmsClientConfig> {
|
|
18
18
|
}
|
|
19
|
-
export
|
|
19
|
+
export type URLComposable = Parameters<typeof acmsPath>[0] | URL | string;
|
|
@@ -2,3 +2,6 @@ export { default as encodeUri } from './encodeUri';
|
|
|
2
2
|
export { default as getMessageFromResponse } from './getMessageFromResponse';
|
|
3
3
|
export { default as isDateString } from './isDateString';
|
|
4
4
|
export * from './typeGuard';
|
|
5
|
+
export { default as parseFormData } from './parseFormData';
|
|
6
|
+
export { default as unique } from './unique';
|
|
7
|
+
export { default as mergeConfig } from './mergeConfig';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 設定オブジェクトを深くマージする関数
|
|
3
|
+
* @param defaults - デフォルト設定
|
|
4
|
+
* @param overrides - マージする設定(優先される)
|
|
5
|
+
* @returns マージされた設定
|
|
6
|
+
*/
|
|
7
|
+
declare function mergeConfig(defaults: Record<string, any>, overrides: Record<string, any>): {
|
|
8
|
+
[x: string]: any;
|
|
9
|
+
};
|
|
10
|
+
export default mergeConfig;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function unique<T>(arr: T[]): T[];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uidev1116/acms-js-sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "a-blog cms JavaScript SDK",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": [
|
|
@@ -39,41 +39,42 @@
|
|
|
39
39
|
"test": "vitest",
|
|
40
40
|
"test:ci": "vitest run",
|
|
41
41
|
"dev": "vite",
|
|
42
|
-
"build": "vite build",
|
|
42
|
+
"build": "tsc -b && vite build",
|
|
43
|
+
"lint": "eslint src --ext .ts,.js",
|
|
44
|
+
"lint:fix": "eslint src --ext .ts,.js --fix",
|
|
43
45
|
"check-update": "npx -p npm-check-updates -c ncu",
|
|
44
|
-
"prepare": "husky
|
|
45
|
-
"prepack": "npm run test:ci && npm run build"
|
|
46
|
+
"prepare": "husky",
|
|
47
|
+
"prepack": "npm run test:ci && npm run lint && npm run build"
|
|
46
48
|
},
|
|
47
49
|
"dependencies": {
|
|
48
|
-
"
|
|
49
|
-
"deepmerge": "^4.3.1"
|
|
50
|
+
"qs": "^6.14.0"
|
|
50
51
|
},
|
|
51
52
|
"devDependencies": {
|
|
52
|
-
"@types/node": "^
|
|
53
|
-
"@
|
|
54
|
-
"@typescript-eslint/
|
|
55
|
-
"
|
|
56
|
-
"eslint": "^
|
|
57
|
-
"eslint-config-prettier": "^
|
|
58
|
-
"
|
|
59
|
-
"
|
|
60
|
-
"
|
|
61
|
-
"
|
|
62
|
-
"
|
|
63
|
-
"
|
|
64
|
-
"
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
"
|
|
68
|
-
"vite-plugin-dts": "^3.7.0",
|
|
69
|
-
"vite-plugin-eslint": "^1.8.1",
|
|
70
|
-
"vitest": "^1.1.3"
|
|
53
|
+
"@types/node": "^24.9.2",
|
|
54
|
+
"@types/qs": "^6.14.0",
|
|
55
|
+
"@typescript-eslint/eslint-plugin": "^8.46.2",
|
|
56
|
+
"@typescript-eslint/parser": "^8.46.2",
|
|
57
|
+
"eslint": "^9.38.0",
|
|
58
|
+
"eslint-config-prettier": "^10.1.8",
|
|
59
|
+
"husky": "^9.1.7",
|
|
60
|
+
"lint-staged": "^16.2.6",
|
|
61
|
+
"prettier": "^3.6.2",
|
|
62
|
+
"typescript": "^5.9.3",
|
|
63
|
+
"vite": "^7.1.12",
|
|
64
|
+
"vite-plugin-dts": "^4.5.4",
|
|
65
|
+
"vitest": "^4.0.4"
|
|
66
|
+
},
|
|
67
|
+
"engines": {
|
|
68
|
+
"node": ">=18.0.0"
|
|
71
69
|
},
|
|
72
70
|
"volta": {
|
|
73
|
-
"node": "
|
|
71
|
+
"node": "24.11.0"
|
|
74
72
|
},
|
|
75
73
|
"lint-staged": {
|
|
76
|
-
"*.{js,ts}":
|
|
74
|
+
"*.{js,ts}": [
|
|
75
|
+
"eslint --fix",
|
|
76
|
+
"prettier --write"
|
|
77
|
+
]
|
|
77
78
|
},
|
|
78
79
|
"tags": [
|
|
79
80
|
"a-blog cms"
|