@uidev1116/acms-js-sdk 0.0.2 → 0.1.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.
@@ -1,72 +1,74 @@
1
- var y = Object.defineProperty;
2
- var g = (t, e, r) => e in t ? y(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r;
3
- var n = (t, e, r) => (g(t, typeof e != "symbol" ? e + "" : e, r), r);
4
- import b from "./acms-path.js";
5
- import { a as i } from "../typeGuard-30fb1DDr.js";
6
- import { A, i as q } from "../index-w7KUzF0v.js";
7
- async function F(t) {
1
+ var E = Object.defineProperty;
2
+ var y = (r, e, t) => e in r ? E(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t;
3
+ var n = (r, e, t) => (y(r, typeof e != "symbol" ? e + "" : e, t), t);
4
+ import { a as A } from "../index-H2fSgwjT.js";
5
+ import { p as D } from "../index-H2fSgwjT.js";
6
+ import { i as a } from "../typeGuard-Jsany_41.js";
7
+ import { A as b, i as q } from "../index-ZZQxXurp.js";
8
+ async function F(r) {
8
9
  try {
9
- const { message: e } = await t.json();
10
+ const { message: e } = await r.json();
10
11
  return e ?? null;
11
12
  } catch {
12
13
  return null;
13
14
  }
14
15
  }
15
- async function P() {
16
+ async function U() {
16
17
  if (typeof fetch > "u") {
17
- const { default: t } = await import("../browser-ponyfill-lYv-p29A.js").then((e) => e.b);
18
- return t;
18
+ const { default: r } = await import("../browser-ponyfill-EPWIFhDK.js").then((e) => e.b);
19
+ return r;
19
20
  }
20
21
  return fetch;
21
22
  }
22
- async function U(...t) {
23
+ async function I(...r) {
23
24
  if (typeof Headers > "u") {
24
- const { Headers: e } = await import("../browser-ponyfill-lYv-p29A.js").then((r) => r.b);
25
- return new e(...t);
25
+ const { Headers: e } = await import("../browser-ponyfill-EPWIFhDK.js").then((t) => t.b);
26
+ return new e(...r);
26
27
  }
27
- return new Headers(...t);
28
+ return new Headers(...r);
28
29
  }
29
- const I = {
30
- responseType: "json"
30
+ const R = {
31
+ responseType: "json",
32
+ acmsPathOptions: {}
31
33
  };
32
- class R {
34
+ class $ {
33
35
  constructor({
34
36
  baseUrl: e,
35
- apiKey: r,
36
- ...a
37
+ apiKey: t,
38
+ ...o
37
39
  }) {
38
40
  n(this, "baseUrl");
39
41
  n(this, "apiKey");
40
42
  n(this, "config");
41
- if (e == null && e === "")
43
+ if (e != null && e === "")
42
44
  throw new Error("baseUrl is required.");
43
- if (r == null && r === "")
45
+ if (t != null && t === "")
44
46
  throw new Error("apiKey is required.");
45
- if (!i(e))
47
+ if (!a(e))
46
48
  throw new Error("baseUrl must be string.");
47
- if (!i(r))
49
+ if (!a(t))
48
50
  throw new Error("apiKey must be string.");
49
- this.baseUrl = e, this.apiKey = r, this.config = {
50
- ...I,
51
- ...a
51
+ this.baseUrl = e, this.apiKey = t, this.config = {
52
+ ...R,
53
+ ...o
52
54
  };
53
55
  }
54
- async request(e, r = {}) {
55
- const a = { ...this.config, ...r }, { requestInit: f, responseType: w } = a, m = await P(), p = this.createUrl(e), l = await this.createFetchOptions(f);
56
+ async request(e, t = {}) {
57
+ const o = { ...this.config, ...t }, { requestInit: h, responseType: w } = o, p = await U(), m = this.createUrl(e), l = await this.createFetchOptions(h);
56
58
  try {
57
- const s = await m(p, l), { ok: d, status: o, statusText: c, headers: E } = s, u = {
59
+ const s = await p(m, l), { ok: d, status: i, statusText: c, headers: g } = s, u = {
58
60
  data: await s[w](),
59
- status: o,
61
+ status: i,
60
62
  statusText: c,
61
- headers: E
63
+ headers: g
62
64
  };
63
65
  if (!d) {
64
- const h = await F(s);
66
+ const f = await F(s);
65
67
  return await Promise.reject(
66
- new A(
67
- `fetch API response status: ${o}${h != null ? `
68
- message is \`${h}\`` : ""}`,
69
- `${o} ${c}`,
68
+ new b(
69
+ `fetch API response status: ${i}${f != null ? `
70
+ message is \`${f}\`` : ""}`,
71
+ `${i} ${c}`,
70
72
  u
71
73
  )
72
74
  );
@@ -83,27 +85,34 @@ class R {
83
85
  }
84
86
  }
85
87
  async createFetchOptions(e) {
86
- const r = await U(e == null ? void 0 : e.headers);
87
- return r.has("X-API-KEY") || r.set("X-API-KEY", this.apiKey), { ...e, headers: r };
88
+ const t = await I(e == null ? void 0 : e.headers);
89
+ return t.has("X-API-KEY") || t.set("X-API-KEY", this.apiKey), { ...e, headers: t };
88
90
  }
89
91
  createUrl(e) {
90
- return i(e) ? new URL(e, this.baseUrl) : e instanceof URL ? new URL(e, this.baseUrl) : new URL(b({ ...e }), this.baseUrl);
92
+ return a(e) ? new URL(e, this.baseUrl) : e instanceof URL ? new URL(e, this.baseUrl) : new URL(
93
+ A({ ...e }, this.config.acmsPathOptions),
94
+ this.baseUrl
95
+ );
91
96
  }
92
- async get(e, r = {}) {
97
+ async get(e, t = {}) {
93
98
  return await this.request(e, {
94
- ...r,
95
- requestInit: { ...r.requestInit, method: "GET" }
99
+ ...t,
100
+ requestInit: { ...t.requestInit, method: "GET" }
96
101
  });
97
102
  }
98
103
  static isAcmsFetchError(e) {
99
104
  return q(e);
100
105
  }
106
+ getConfig() {
107
+ return this.config;
108
+ }
101
109
  }
102
- function L(...t) {
103
- return new R(...t);
110
+ function T(...r) {
111
+ return new $(...r);
104
112
  }
105
113
  export {
106
- b as acmsPath,
107
- L as createClient,
108
- q as isAcmsFetchError
114
+ A as acmsPath,
115
+ T as createClient,
116
+ q as isAcmsFetchError,
117
+ D as parseAcmsPath
109
118
  };
@@ -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?: Partial<AcmsClientConfig>): 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,2 @@
1
+ import { type AcmsPathSegments } from './types';
2
+ export declare const defaultAcmsPathSegments: AcmsPathSegments;
@@ -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';