@uidev1116/acms-js-sdk 0.0.3 → 0.1.1

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.
@@ -1,94 +1,6 @@
1
- import { i as g, a as l } from "../typeGuard-30fb1DDr.js";
2
- function s(n) {
3
- return encodeURIComponent(n).replace(
4
- /[!'()*]/g,
5
- (i) => `%${i.charCodeAt(0).toString(16)}`
6
- );
7
- }
8
- function d(n) {
9
- return !isNaN(Date.parse(n));
10
- }
11
- function D(n = {}) {
12
- let i = [
13
- "blog",
14
- "category",
15
- "entry",
16
- "user",
17
- "tag",
18
- "field",
19
- "span",
20
- "date",
21
- "page",
22
- "order",
23
- "limit",
24
- "keyword",
25
- "tpl",
26
- "api"
27
- ].reduce((t, e) => {
28
- const $ = n[e];
29
- if ($ == null)
30
- return t;
31
- if (e === "blog") {
32
- const r = n[e];
33
- return g(r) ? `${t}/bid/${r}` : `${t}/${r.split("/").map(s).join("/")}`;
34
- }
35
- if (e === "category") {
36
- const r = n[e];
37
- return g(r) ? `${t}/cid/${r}` : Array.isArray(r) ? `${t}/${r.map(s).join("/")}` : `${t}/${s(r)}`;
38
- }
39
- if (e === "entry") {
40
- const r = n[e];
41
- return g(r) ? `${t}/eid/${r}` : `${t}/${s(r)}`;
42
- }
43
- if (e === "user") {
44
- const r = n[e];
45
- return `${t}/uid/${r}`;
46
- }
47
- if (e === "field") {
48
- const r = n[e];
49
- return `${t}/field/${r.split("/").map(s).join("/")}`;
50
- }
51
- if (e === "span") {
52
- const { start: r, end: o } = {
53
- start: "1000-01-01 00:00:00",
54
- end: "9999-12-31 23:59:59",
55
- ...n[e]
56
- };
57
- if (l(r) && !d(r))
58
- throw new Error(`Invalid start date: ${r}`);
59
- if (l(o) && !d(o))
60
- throw new Error(`Invalid end date: ${o}`);
61
- return `${t}/${s(m(new Date(r)))}/-/${s(
62
- m(new Date(o))
63
- )}`;
64
- }
65
- if (e === "date") {
66
- if (n.span != null)
67
- return t;
68
- const { year: r, month: o, day: u } = n[e];
69
- return [r, o, u].reduce((a, c) => c == null ? a : `${a}/${c}`, t);
70
- }
71
- if (e === "page") {
72
- const r = n[e];
73
- return r === 1 ? t : `${t}/page/${r}`;
74
- }
75
- if (e === "tpl") {
76
- const r = n[e];
77
- return `${t}/tpl/${r.split("/").map(s).join("/")}`;
78
- }
79
- return Array.isArray($) ? $.length > 0 ? `${t}/${e}/${$.map(s).join("/")}` : t : `${t}/${e}/${s($)}`;
80
- }, "");
81
- /\.[^/.]+$/.test(i) || (i += "/");
82
- const f = new URLSearchParams(n.searchParams);
83
- return f.size > 0 && (i += `?${f.toString()}`), i.startsWith("/") ? i.slice(1) : i;
84
- }
85
- function m(n) {
86
- function i(u) {
87
- return u < 10 ? "0" + u : u;
88
- }
89
- const f = n.getFullYear(), t = i(n.getMonth() + 1), e = i(n.getDate()), $ = i(n.getHours()), r = i(n.getMinutes()), o = i(n.getSeconds());
90
- return `${f}-${t}-${e} ${$}:${r}:${o}`;
91
- }
1
+ import { a as p, p as r } from "../index-H2fSgwjT.js";
2
+ import "../typeGuard-Jsany_41.js";
92
3
  export {
93
- D as default
4
+ p as acmsPath,
5
+ r as parseAcmsPath
94
6
  };
@@ -1,5 +1,5 @@
1
- import { i as m } from "../index-w7KUzF0v.js";
2
- import "../typeGuard-30fb1DDr.js";
1
+ import { i as m } from "../index-ZZQxXurp.js";
2
+ import "../typeGuard-Jsany_41.js";
3
3
  export {
4
4
  m as isAcmsFetchError
5
5
  };
@@ -0,0 +1,328 @@
1
+ import { a as w, i as h } from "./typeGuard-Jsany_41.js";
2
+ var Z = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
3
+ function M(e) {
4
+ return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
5
+ }
6
+ var I = function(r) {
7
+ return P(r) && !D(r);
8
+ };
9
+ function P(e) {
10
+ return !!e && typeof e == "object";
11
+ }
12
+ function D(e) {
13
+ var r = Object.prototype.toString.call(e);
14
+ return r === "[object RegExp]" || r === "[object Date]" || U(e);
15
+ }
16
+ var E = typeof Symbol == "function" && Symbol.for, T = E ? Symbol.for("react.element") : 60103;
17
+ function U(e) {
18
+ return e.$$typeof === T;
19
+ }
20
+ function N(e) {
21
+ return Array.isArray(e) ? [] : {};
22
+ }
23
+ function $(e, r) {
24
+ return r.clone !== !1 && r.isMergeableObject(e) ? p(N(e), e, r) : e;
25
+ }
26
+ function _(e, r, t) {
27
+ return e.concat(r).map(function(a) {
28
+ return $(a, t);
29
+ });
30
+ }
31
+ function R(e, r) {
32
+ if (!r.customMerge)
33
+ return p;
34
+ var t = r.customMerge(e);
35
+ return typeof t == "function" ? t : p;
36
+ }
37
+ function F(e) {
38
+ return Object.getOwnPropertySymbols ? Object.getOwnPropertySymbols(e).filter(function(r) {
39
+ return Object.propertyIsEnumerable.call(e, r);
40
+ }) : [];
41
+ }
42
+ function O(e) {
43
+ return Object.keys(e).concat(F(e));
44
+ }
45
+ function S(e, r) {
46
+ try {
47
+ return r in e;
48
+ } catch {
49
+ return !1;
50
+ }
51
+ }
52
+ function K(e, r) {
53
+ return S(e, r) && !(Object.hasOwnProperty.call(e, r) && Object.propertyIsEnumerable.call(e, r));
54
+ }
55
+ function Y(e, r, t) {
56
+ var a = {};
57
+ return t.isMergeableObject(e) && O(e).forEach(function(n) {
58
+ a[n] = $(e[n], t);
59
+ }), O(r).forEach(function(n) {
60
+ K(e, n) || (S(e, n) && t.isMergeableObject(r[n]) ? a[n] = R(n, t)(e[n], r[n], t) : a[n] = $(r[n], t));
61
+ }), a;
62
+ }
63
+ function p(e, r, t) {
64
+ t = t || {}, t.arrayMerge = t.arrayMerge || _, t.isMergeableObject = t.isMergeableObject || I, t.cloneUnlessOtherwiseSpecified = $;
65
+ var a = Array.isArray(r), n = Array.isArray(e), u = a === n;
66
+ return u ? a ? t.arrayMerge(e, r, t) : Y(e, r, t) : $(r, t);
67
+ }
68
+ p.all = function(r, t) {
69
+ if (!Array.isArray(r))
70
+ throw new Error("first argument should be an array");
71
+ return r.reduce(function(a, n) {
72
+ return p(a, n, t);
73
+ }, {});
74
+ };
75
+ var C = p, L = C;
76
+ const v = /* @__PURE__ */ M(L);
77
+ function g(e) {
78
+ return encodeURIComponent(e).replace(
79
+ /[!'()*]/g,
80
+ (r) => `%${r.charCodeAt(0).toString(16)}`
81
+ );
82
+ }
83
+ function y(e) {
84
+ return !isNaN(Date.parse(e));
85
+ }
86
+ const A = {
87
+ bid: "bid",
88
+ cid: "cid",
89
+ eid: "eid",
90
+ uid: "uid",
91
+ tag: "tag",
92
+ field: "field",
93
+ span: "-",
94
+ page: "page",
95
+ order: "order",
96
+ limit: "limit",
97
+ keyword: "keyword",
98
+ admin: "admin",
99
+ tpl: "tpl",
100
+ api: "api"
101
+ };
102
+ function m(e) {
103
+ function r(s) {
104
+ return s < 10 ? "0" + s : s;
105
+ }
106
+ const t = e.getFullYear(), a = r(e.getMonth() + 1), n = r(e.getDate()), u = r(e.getHours()), o = r(e.getMinutes()), c = r(e.getSeconds());
107
+ return `${t}-${a}-${n} ${u}:${o}:${c}`;
108
+ }
109
+ const z = {
110
+ segments: A
111
+ };
112
+ function k(e, r = {}) {
113
+ const t = G(e) ? e : H(e), { segments: a } = v(z, r);
114
+ let n = [
115
+ "blog",
116
+ "admin",
117
+ "category",
118
+ "entry",
119
+ "user",
120
+ "tag",
121
+ "field",
122
+ "span",
123
+ "date",
124
+ "page",
125
+ "order",
126
+ "limit",
127
+ "keyword",
128
+ "tpl",
129
+ "api"
130
+ ].reduce((o, c) => {
131
+ const s = t[c];
132
+ if (s == null)
133
+ return o;
134
+ if (c === "blog") {
135
+ const i = t[c];
136
+ return w(i) ? `${o}/${a.bid}/${i}` : `${o}/${i.split("/").map(g).join("/")}`;
137
+ }
138
+ if (c === "category") {
139
+ const i = t[c];
140
+ return w(i) ? `${o}/${a.cid}/${i}` : Array.isArray(i) ? `${o}/${i.map(g).join("/")}` : `${o}/${g(i)}`;
141
+ }
142
+ if (c === "entry") {
143
+ const i = t[c];
144
+ return w(i) ? `${o}/${a.eid}/${i}` : `${o}/${g(i)}`;
145
+ }
146
+ if (c === "user") {
147
+ const i = t[c];
148
+ return `${o}/${a.uid}/${i}`;
149
+ }
150
+ if (c === "field") {
151
+ const i = t[c];
152
+ return `${o}/${a.field}/${i.split("/").map(g).join("/")}`;
153
+ }
154
+ if (c === "span") {
155
+ const { start: i, end: l } = {
156
+ start: "1000-01-01 00:00:00",
157
+ end: "9999-12-31 23:59:59",
158
+ ...t[c]
159
+ };
160
+ if (h(i) && !y(i))
161
+ throw new Error(`Invalid start date: ${i}`);
162
+ if (h(l) && !y(l))
163
+ throw new Error(`Invalid end date: ${l}`);
164
+ return `${o}/${g(m(new Date(i)))}/${a.span}/${g(m(new Date(l)))}`;
165
+ }
166
+ if (c === "date") {
167
+ if (t.span != null)
168
+ return o;
169
+ const { year: i, month: l, day: f } = t[c];
170
+ return [i, l, f].reduce((d, b) => b == null ? d : `${d}/${b}`, o);
171
+ }
172
+ if (c === "page") {
173
+ const i = t[c];
174
+ return i === 1 ? o : `${o}/${a.page}/${i}`;
175
+ }
176
+ if (c === "tpl") {
177
+ const i = t[c];
178
+ return `${o}/${a.tpl}/${i.split("/").map(g).join("/")}`;
179
+ }
180
+ return Array.isArray(s) ? s.length > 0 ? `${o}/${a[c]}/${s.map(g).join("/")}` : o : `${o}/${a[c]}/${g(
181
+ s
182
+ )}`;
183
+ }, "");
184
+ /\.[^/.]+$/.test(n) || (n += "/");
185
+ const u = new URLSearchParams(t.searchParams);
186
+ return u.size > 0 && (n += `?${u.toString()}`), n.startsWith("/") ? n.slice(1) : n;
187
+ }
188
+ function G(e) {
189
+ return "blog" in e || "category" in e || "entry" in e || "user" in e || "searchParams" in e;
190
+ }
191
+ function H(e) {
192
+ return {
193
+ blog: e.bid,
194
+ category: e.cid,
195
+ entry: e.eid,
196
+ user: e.uid,
197
+ tag: e.tag,
198
+ field: e.field,
199
+ span: e.span,
200
+ date: e.date,
201
+ page: e.page,
202
+ order: e.order,
203
+ limit: e.limit,
204
+ keyword: e.keyword,
205
+ admin: e.admin,
206
+ tpl: e.tpl,
207
+ api: e.api
208
+ };
209
+ }
210
+ const V = {
211
+ segments: A
212
+ };
213
+ function x(e, r = {}) {
214
+ const { segments: t } = v(
215
+ V,
216
+ r
217
+ ), a = e.split("/").filter((s) => s), n = {}, u = [], o = Object.keys(t), c = Object.values(t);
218
+ for (let s = 0; s < a.length; s++) {
219
+ const i = a[s];
220
+ if (c.includes(i)) {
221
+ const l = o.find(
222
+ (f) => t[f] === i
223
+ );
224
+ if (l !== void 0) {
225
+ const f = a[s + 1];
226
+ if (f !== void 0)
227
+ switch (l) {
228
+ case "bid":
229
+ case "uid":
230
+ case "cid":
231
+ case "eid":
232
+ case "page":
233
+ case "limit":
234
+ n[l] = parseInt(f, 10), s++;
235
+ break;
236
+ case "admin":
237
+ case "api":
238
+ case "keyword":
239
+ n[l] = f, s++;
240
+ break;
241
+ case "tpl":
242
+ n.tpl = j(a, s + 1, c), s += n.tpl.split("/").length;
243
+ break;
244
+ case "field":
245
+ n.field = j(a, s + 1, c), s += n.field.split("/").length;
246
+ break;
247
+ case "tag":
248
+ n.tag = j(a, s + 1, c).split("/").map((d) => d.trim()), s += n.tag.length;
249
+ break;
250
+ case "span": {
251
+ const [d, b] = W(a[s - 1], f);
252
+ d !== void 0 && b !== void 0 && (n.span = { start: d, end: b }, u.pop(), s++);
253
+ break;
254
+ }
255
+ }
256
+ }
257
+ } else
258
+ u.push(i);
259
+ }
260
+ for (let s = 0; s < u.length; s++) {
261
+ const i = u[s];
262
+ if (q(i)) {
263
+ const l = i, f = u[s + 1];
264
+ if (f !== void 0 && B(f)) {
265
+ const d = u[s + 2];
266
+ if (d !== void 0 && J(d)) {
267
+ n.date = {
268
+ year: parseInt(l, 10),
269
+ month: parseInt(f, 10),
270
+ day: parseInt(d, 10)
271
+ }, u.splice(s, 3);
272
+ continue;
273
+ }
274
+ n.date = {
275
+ year: parseInt(l, 10),
276
+ month: parseInt(f, 10)
277
+ }, u.splice(s, 2);
278
+ continue;
279
+ }
280
+ n.date = { year: parseInt(l, 10) }, u.splice(s, 1);
281
+ continue;
282
+ }
283
+ }
284
+ return n.page === void 0 && (n.page = 1), n.span === void 0 && (n.span = Q(n)), n.unresolvedPath = u.join("/"), n;
285
+ }
286
+ function j(e, r, t) {
287
+ const a = [];
288
+ for (let n = r; n < e.length && !t.includes(e[n]); n++)
289
+ a.push(e[n]);
290
+ return a.join("/");
291
+ }
292
+ function W(e, r) {
293
+ const t = y(e) ? m(new Date(e)) : void 0, a = y(r) ? m(new Date(r)) : void 0;
294
+ return [t, a];
295
+ }
296
+ function q(e) {
297
+ const r = parseInt(e, 10);
298
+ return r >= 1e3 && r <= 9999;
299
+ }
300
+ function B(e) {
301
+ const r = parseInt(e, 10);
302
+ return r >= 1 && r <= 12;
303
+ }
304
+ function J(e) {
305
+ const r = parseInt(e, 10);
306
+ return r >= 1 && r <= 31;
307
+ }
308
+ function Q(e) {
309
+ let r = new Date(1e3, 0, 1, 0, 0, 0), t = new Date(9999, 11, 31, 23, 59, 59);
310
+ return e.date !== void 0 && (r = new Date(
311
+ e.date.year,
312
+ (e.date.month ?? 1) - 1,
313
+ e.date.day ?? 1
314
+ ), t = new Date(
315
+ e.date.year,
316
+ (e.date.month ?? 12) - 1,
317
+ e.date.day ?? 31,
318
+ 23,
319
+ 59,
320
+ 59
321
+ )), { start: m(r), end: m(t) };
322
+ }
323
+ export {
324
+ k as a,
325
+ Z as c,
326
+ M as g,
327
+ x as p
328
+ };
@@ -0,0 +1 @@
1
+ "use strict";const $=require("./typeGuard-eqTQ9U-x.cjs");var M=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function S(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var P=function(r){return I(r)&&!D(r)};function I(e){return!!e&&typeof e=="object"}function D(e){var r=Object.prototype.toString.call(e);return r==="[object RegExp]"||r==="[object Date]"||T(e)}var E=typeof Symbol=="function"&&Symbol.for,N=E?Symbol.for("react.element"):60103;function T(e){return e.$$typeof===N}function U(e){return Array.isArray(e)?[]:{}}function y(e,r){return r.clone!==!1&&r.isMergeableObject(e)?m(U(e),e,r):e}function _(e,r,t){return e.concat(r).map(function(a){return y(a,t)})}function R(e,r){if(!r.customMerge)return m;var t=r.customMerge(e);return typeof t=="function"?t:m}function F(e){return Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(e).filter(function(r){return Object.propertyIsEnumerable.call(e,r)}):[]}function h(e){return Object.keys(e).concat(F(e))}function O(e,r){try{return r in e}catch{return!1}}function C(e,r){return O(e,r)&&!(Object.hasOwnProperty.call(e,r)&&Object.propertyIsEnumerable.call(e,r))}function G(e,r,t){var a={};return t.isMergeableObject(e)&&h(e).forEach(function(n){a[n]=y(e[n],t)}),h(r).forEach(function(n){C(e,n)||(O(e,n)&&t.isMergeableObject(r[n])?a[n]=R(n,t)(e[n],r[n],t):a[n]=y(r[n],t))}),a}function m(e,r,t){t=t||{},t.arrayMerge=t.arrayMerge||_,t.isMergeableObject=t.isMergeableObject||P,t.cloneUnlessOtherwiseSpecified=y;var a=Array.isArray(r),n=Array.isArray(e),u=a===n;return u?a?t.arrayMerge(e,r,t):G(e,r,t):y(r,t)}m.all=function(r,t){if(!Array.isArray(r))throw new Error("first argument should be an array");return r.reduce(function(a,n){return m(a,n,t)},{})};var K=m,Y=K;const A=S(Y);function g(e){return encodeURIComponent(e).replace(/[!'()*]/g,r=>`%${r.charCodeAt(0).toString(16)}`)}function j(e){return!isNaN(Date.parse(e))}const v={bid:"bid",cid:"cid",eid:"eid",uid:"uid",tag:"tag",field:"field",span:"-",page:"page",order:"order",limit:"limit",keyword:"keyword",admin:"admin",tpl:"tpl",api:"api"};function p(e){function r(s){return s<10?"0"+s:s}const t=e.getFullYear(),a=r(e.getMonth()+1),n=r(e.getDate()),u=r(e.getHours()),o=r(e.getMinutes()),c=r(e.getSeconds());return`${t}-${a}-${n} ${u}:${o}:${c}`}const L={segments:v};function q(e,r={}){const t=z(e)?e:H(e),{segments:a}=A(L,r);let n=["blog","admin","category","entry","user","tag","field","span","date","page","order","limit","keyword","tpl","api"].reduce((o,c)=>{const s=t[c];if(s==null)return o;if(c==="blog"){const i=t[c];return $.isNumber(i)?`${o}/${a.bid}/${i}`:`${o}/${i.split("/").map(g).join("/")}`}if(c==="category"){const i=t[c];return $.isNumber(i)?`${o}/${a.cid}/${i}`:Array.isArray(i)?`${o}/${i.map(g).join("/")}`:`${o}/${g(i)}`}if(c==="entry"){const i=t[c];return $.isNumber(i)?`${o}/${a.eid}/${i}`:`${o}/${g(i)}`}if(c==="user"){const i=t[c];return`${o}/${a.uid}/${i}`}if(c==="field"){const i=t[c];return`${o}/${a.field}/${i.split("/").map(g).join("/")}`}if(c==="span"){const{start:i,end:l}={start:"1000-01-01 00:00:00",end:"9999-12-31 23:59:59",...t[c]};if($.isString(i)&&!j(i))throw new Error(`Invalid start date: ${i}`);if($.isString(l)&&!j(l))throw new Error(`Invalid end date: ${l}`);return`${o}/${g(p(new Date(i)))}/${a.span}/${g(p(new Date(l)))}`}if(c==="date"){if(t.span!=null)return o;const{year:i,month:l,day:f}=t[c];return[i,l,f].reduce((d,b)=>b==null?d:`${d}/${b}`,o)}if(c==="page"){const i=t[c];return i===1?o:`${o}/${a.page}/${i}`}if(c==="tpl"){const i=t[c];return`${o}/${a.tpl}/${i.split("/").map(g).join("/")}`}return Array.isArray(s)?s.length>0?`${o}/${a[c]}/${s.map(g).join("/")}`:o:`${o}/${a[c]}/${g(s)}`},"");/\.[^/.]+$/.test(n)||(n+="/");const u=new URLSearchParams(t.searchParams);return u.size>0&&(n+=`?${u.toString()}`),n.startsWith("/")?n.slice(1):n}function z(e){return"blog"in e||"category"in e||"entry"in e||"user"in e||"searchParams"in e}function H(e){return{blog:e.bid,category:e.cid,entry:e.eid,user:e.uid,tag:e.tag,field:e.field,span:e.span,date:e.date,page:e.page,order:e.order,limit:e.limit,keyword:e.keyword,admin:e.admin,tpl:e.tpl,api:e.api}}const V={segments:v};function W(e,r={}){const{segments:t}=A(V,r),a=e.split("/").filter(s=>s),n={},u=[],o=Object.keys(t),c=Object.values(t);for(let s=0;s<a.length;s++){const i=a[s];if(c.includes(i)){const l=o.find(f=>t[f]===i);if(l!==void 0){const f=a[s+1];if(f!==void 0)switch(l){case"bid":case"uid":case"cid":case"eid":case"page":case"limit":n[l]=parseInt(f,10),s++;break;case"admin":case"api":case"keyword":n[l]=f,s++;break;case"tpl":n.tpl=w(a,s+1,c),s+=n.tpl.split("/").length;break;case"field":n.field=w(a,s+1,c),s+=n.field.split("/").length;break;case"tag":n.tag=w(a,s+1,c).split("/").map(d=>d.trim()),s+=n.tag.length;break;case"span":{const[d,b]=B(a[s-1],f);d!==void 0&&b!==void 0&&(n.span={start:d,end:b},u.pop(),s++);break}}}}else u.push(i)}for(let s=0;s<u.length;s++){const i=u[s];if(J(i)){const l=i,f=u[s+1];if(f!==void 0&&Q(f)){const d=u[s+2];if(d!==void 0&&X(d)){n.date={year:parseInt(l,10),month:parseInt(f,10),day:parseInt(d,10)},u.splice(s,3);continue}n.date={year:parseInt(l,10),month:parseInt(f,10)},u.splice(s,2);continue}n.date={year:parseInt(l,10)},u.splice(s,1);continue}}return n.page===void 0&&(n.page=1),n.span===void 0&&(n.span=Z(n)),n.unresolvedPath=u.join("/"),n}function w(e,r,t){const a=[];for(let n=r;n<e.length&&!t.includes(e[n]);n++)a.push(e[n]);return a.join("/")}function B(e,r){const t=j(e)?p(new Date(e)):void 0,a=j(r)?p(new Date(r)):void 0;return[t,a]}function J(e){const r=parseInt(e,10);return r>=1e3&&r<=9999}function Q(e){const r=parseInt(e,10);return r>=1&&r<=12}function X(e){const r=parseInt(e,10);return r>=1&&r<=31}function Z(e){let r=new Date(1e3,0,1,0,0,0),t=new Date(9999,11,31,23,59,59);return e.date!==void 0&&(r=new Date(e.date.year,(e.date.month??1)-1,e.date.day??1),t=new Date(e.date.year,(e.date.month??12)-1,e.date.day??31,23,59,59)),{start:p(r),end:p(t)}}exports.acmsPath=q;exports.commonjsGlobal=M;exports.getDefaultExportFromCjs=S;exports.parseAcmsPath=W;
@@ -1,7 +1,7 @@
1
1
  var i = Object.defineProperty;
2
2
  var h = (r, s, e) => s in r ? i(r, s, { enumerable: !0, configurable: !0, writable: !0, value: e }) : r[s] = e;
3
3
  var t = (r, s, e) => (h(r, typeof s != "symbol" ? s + "" : s, e), e);
4
- import { b as m } from "./typeGuard-30fb1DDr.js";
4
+ import { b as m } from "./typeGuard-Jsany_41.js";
5
5
  class a extends Error {
6
6
  constructor(e, c, o, n) {
7
7
  super(e, n);
@@ -8,7 +8,7 @@ function e(t) {
8
8
  return typeof t == "object" && t !== null;
9
9
  }
10
10
  export {
11
- n as a,
11
+ r as a,
12
12
  e as b,
13
- r as i
13
+ n as i
14
14
  };
@@ -1,5 +1,5 @@
1
- import { type AcmsContext } from '../lib/acmsPath';
2
- import { type AcmsClientConfig, type AcmsResponse } from '../types';
1
+ import { type AcmsPathParams } from '../lib/acmsPath';
2
+ import { type AcmsClientOptions, type AcmsClientConfig, type AcmsResponse } from '../types';
3
3
  export default class AcmsClient {
4
4
  private readonly baseUrl;
5
5
  private readonly apiKey;
@@ -7,10 +7,11 @@ export default class AcmsClient {
7
7
  constructor({ baseUrl, apiKey, ...options }: {
8
8
  baseUrl: string;
9
9
  apiKey: string;
10
- } & Partial<AcmsClientConfig>);
10
+ } & AcmsClientOptions);
11
11
  private request;
12
12
  private createFetchOptions;
13
13
  private createUrl;
14
- get<T = any>(acmsContextOrUrl: AcmsContext | URL | string, options?: Partial<AcmsClientConfig>): Promise<AcmsResponse<T>>;
14
+ get<T = any>(acmsPathParamsOrUrl: AcmsPathParams | URL | string, options?: AcmsClientOptions): Promise<AcmsResponse<T>>;
15
15
  static isAcmsFetchError(payload: any): boolean;
16
+ getConfig(): AcmsClientConfig;
16
17
  }
@@ -1,4 +1,6 @@
1
1
  export { default as createClient } from './createClient';
2
- export { default as acmsPath } from './lib/acmsPath';
2
+ export { default as acmsPath } from './lib/acmsPath/acmsPath';
3
+ export { default as parseAcmsPath } from './lib/acmsPath/parseAcmsPath';
3
4
  export * from './lib/typeGuard';
4
5
  export type * from './types';
6
+ export type * from './lib/acmsPath/types';
@@ -0,0 +1,2 @@
1
+ import type { AcmsContext, AcmsPathOptions, AcmsPathParams } from './types';
2
+ export default function acmsPath(paramsOrCtx: AcmsPathParams | AcmsContext, options?: AcmsPathOptions): string;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,16 @@
1
+ export declare const defaultAcmsPathSegments: {
2
+ readonly bid: "bid";
3
+ readonly cid: "cid";
4
+ readonly eid: "eid";
5
+ readonly uid: "uid";
6
+ readonly tag: "tag";
7
+ readonly field: "field";
8
+ readonly span: "-";
9
+ readonly page: "page";
10
+ readonly order: "order";
11
+ readonly limit: "limit";
12
+ readonly keyword: "keyword";
13
+ readonly admin: "admin";
14
+ readonly tpl: "tpl";
15
+ readonly api: "api";
16
+ };
@@ -1,3 +1,3 @@
1
- import { type AcmsContext } from './types';
2
- export default function acmsPath(acmsContext?: AcmsContext): string;
3
- export type { AcmsContext };
1
+ export { default as acmsPath } from './acmsPath';
2
+ export { default as parseAcmsPath } from './parseAcmsPath';
3
+ export * from './types';
@@ -0,0 +1,2 @@
1
+ import type { AcmsContext, ParseAcmsPathOptions } from './types';
2
+ export default function parseAcmsPath(path: string, options?: ParseAcmsPathOptions): AcmsContext;
@@ -0,0 +1 @@
1
+ export {};
@@ -1,4 +1,4 @@
1
- export interface AcmsContext {
1
+ export interface AcmsPathParams {
2
2
  blog?: string | number;
3
3
  category?: string | string[] | number;
4
4
  entry?: string | number;
@@ -18,7 +18,63 @@ export interface AcmsContext {
18
18
  order?: string;
19
19
  limit?: number;
20
20
  keyword?: string;
21
+ admin?: string;
21
22
  tpl?: string;
22
23
  api?: string;
23
24
  searchParams?: ConstructorParameters<typeof URLSearchParams>[0];
24
25
  }
26
+ export interface AcmsContext {
27
+ bid?: number;
28
+ cid?: number;
29
+ eid?: number;
30
+ uid?: number;
31
+ tag?: string[];
32
+ field?: string;
33
+ span?: {
34
+ start: string | Date;
35
+ end: string | Date;
36
+ };
37
+ date?: {
38
+ year: number;
39
+ month?: number;
40
+ day?: number;
41
+ };
42
+ page?: number;
43
+ order?: string;
44
+ limit?: number;
45
+ keyword?: string;
46
+ admin?: string;
47
+ tpl?: string;
48
+ api?: string;
49
+ unresolvedPath?: string;
50
+ }
51
+ export interface AcmsPathSegments {
52
+ bid: string;
53
+ admin: string;
54
+ cid: string;
55
+ eid: string;
56
+ uid: string;
57
+ tag: string;
58
+ field: string;
59
+ span: string;
60
+ page: string;
61
+ order: string;
62
+ limit: string;
63
+ keyword: string;
64
+ tpl: string;
65
+ api: string;
66
+ }
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
+ export interface AcmsPathConfig {
71
+ segments: AcmsPathSegments;
72
+ }
73
+ export interface ParseAcmsPathConfig {
74
+ segments: AcmsPathSegments;
75
+ }
76
+ export interface AcmsPathOptions extends RecursivePartial<AcmsPathConfig> {
77
+ }
78
+ export interface ParseAcmsPathOptions extends RecursivePartial<ParseAcmsPathConfig> {
79
+ }
80
+ export {};
@@ -0,0 +1 @@
1
+ export declare function formatDate(date: Date): string;
@@ -1,3 +1,4 @@
1
+ import { AcmsPathOptions } from '../lib/acmsPath';
1
2
  export interface AcmsResponse<T> {
2
3
  data: T;
3
4
  status: number;
@@ -8,4 +9,11 @@ export type ResponseType = 'arrayBuffer' | 'blob' | 'formData' | 'json' | 'text'
8
9
  export interface AcmsClientConfig {
9
10
  requestInit?: RequestInit;
10
11
  responseType: ResponseType;
12
+ acmsPathOptions?: AcmsPathOptions;
11
13
  }
14
+ type RecursivePartial<T> = {
15
+ [P in keyof T]?: T[P] extends Array<infer U> ? Array<RecursivePartial<U>> : T[P] extends object ? RecursivePartial<T[P]> : T[P];
16
+ };
17
+ export interface AcmsClientOptions extends RecursivePartial<AcmsClientConfig> {
18
+ }
19
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uidev1116/acms-js-sdk",
3
- "version": "0.0.3",
3
+ "version": "0.1.1",
4
4
  "description": "a-blog cms JavaScript SDK",
5
5
  "type": "module",
6
6
  "files": [
@@ -45,7 +45,8 @@
45
45
  "prepack": "npm run test:ci && npm run build"
46
46
  },
47
47
  "dependencies": {
48
- "cross-fetch": "^4.0.0"
48
+ "cross-fetch": "^4.0.0",
49
+ "deepmerge": "^4.3.1"
49
50
  },
50
51
  "devDependencies": {
51
52
  "@types/node": "^20.10.7",