the-moby-effect 1.43.0-alpha.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.
Files changed (63) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +42 -0
  3. package/dist/src/agent-helpers.d.ts +59 -0
  4. package/dist/src/agent-helpers.js +84 -0
  5. package/dist/src/agent-helpers.js.map +1 -0
  6. package/dist/src/configs.d.ts +105 -0
  7. package/dist/src/configs.js +29 -0
  8. package/dist/src/configs.js.map +1 -0
  9. package/dist/src/containers.d.ts +611 -0
  10. package/dist/src/containers.js +82 -0
  11. package/dist/src/containers.js.map +1 -0
  12. package/dist/src/custom-helpers.d.ts +23 -0
  13. package/dist/src/custom-helpers.js +41 -0
  14. package/dist/src/custom-helpers.js.map +1 -0
  15. package/dist/src/distribution.d.ts +28 -0
  16. package/dist/src/distribution.js +21 -0
  17. package/dist/src/distribution.js.map +1 -0
  18. package/dist/src/execs.d.ts +69 -0
  19. package/dist/src/execs.js +26 -0
  20. package/dist/src/execs.js.map +1 -0
  21. package/dist/src/images.d.ts +657 -0
  22. package/dist/src/images.js +61 -0
  23. package/dist/src/images.js.map +1 -0
  24. package/dist/src/index.d.ts +38 -0
  25. package/dist/src/index.js +38 -0
  26. package/dist/src/index.js.map +1 -0
  27. package/dist/src/networks.d.ts +151 -0
  28. package/dist/src/networks.js +40 -0
  29. package/dist/src/networks.js.map +1 -0
  30. package/dist/src/nodes.d.ts +99 -0
  31. package/dist/src/nodes.js +27 -0
  32. package/dist/src/nodes.js.map +1 -0
  33. package/dist/src/plugins.d.ts +253 -0
  34. package/dist/src/plugins.js +47 -0
  35. package/dist/src/plugins.js.map +1 -0
  36. package/dist/src/request-helpers.d.ts +6 -0
  37. package/dist/src/request-helpers.js +15 -0
  38. package/dist/src/request-helpers.js.map +1 -0
  39. package/dist/src/schemas.d.ts +7279 -0
  40. package/dist/src/schemas.js +3772 -0
  41. package/dist/src/schemas.js.map +1 -0
  42. package/dist/src/secrets.d.ts +100 -0
  43. package/dist/src/secrets.js +29 -0
  44. package/dist/src/secrets.js.map +1 -0
  45. package/dist/src/services.d.ts +185 -0
  46. package/dist/src/services.js +32 -0
  47. package/dist/src/services.js.map +1 -0
  48. package/dist/src/session.d.ts +29 -0
  49. package/dist/src/session.js +20 -0
  50. package/dist/src/session.js.map +1 -0
  51. package/dist/src/swarm.d.ts +80 -0
  52. package/dist/src/swarm.js +39 -0
  53. package/dist/src/swarm.js.map +1 -0
  54. package/dist/src/system.d.ts +100 -0
  55. package/dist/src/system.js +40 -0
  56. package/dist/src/system.js.map +1 -0
  57. package/dist/src/tasks.d.ts +102 -0
  58. package/dist/src/tasks.js +26 -0
  59. package/dist/src/tasks.js.map +1 -0
  60. package/dist/src/volumes.d.ts +143 -0
  61. package/dist/src/volumes.js +29 -0
  62. package/dist/src/volumes.js.map +1 -0
  63. package/package.json +66 -0
@@ -0,0 +1,253 @@
1
+ import { Context, Effect, Layer, Scope, Stream } from "effect";
2
+ import { IMobyConnectionAgent, MobyConnectionOptions } from "./agent-helpers.js";
3
+ import { Plugin, PluginPrivilege } from "./schemas.js";
4
+ declare const PluginsError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").Equals<Omit<A, keyof import("effect/Equal").Equal>, {}> extends true ? void : { readonly [P in keyof A as P extends "_tag" | keyof import("effect/Equal").Equal ? never : P]: A[P]; }) => import("effect/Cause").YieldableError & {
5
+ readonly _tag: "PluginsError";
6
+ } & Readonly<A>;
7
+ export declare class PluginsError extends PluginsError_base<{
8
+ method: string;
9
+ message: string;
10
+ }> {
11
+ }
12
+ export interface PluginListOptions {
13
+ /**
14
+ * A JSON encoded value of the filters (a `map[string][]string`) to process
15
+ * on the plugin list.
16
+ *
17
+ * Available filters:
18
+ *
19
+ * - `capability=<capability name>`
20
+ * - `enable=<true>|<false>`
21
+ */
22
+ readonly filters?: {
23
+ compatibility?: [string];
24
+ enable?: ["true" | "false"];
25
+ };
26
+ }
27
+ export interface GetPluginPrivilegesOptions {
28
+ /**
29
+ * The name of the plugin. The `:latest` tag is optional, and is the default
30
+ * if omitted.
31
+ */
32
+ readonly remote: string;
33
+ }
34
+ export interface PluginPullOptions {
35
+ /**
36
+ * Remote reference for plugin to install.
37
+ *
38
+ * The `:latest` tag is optional, and is used as the default if omitted.
39
+ */
40
+ readonly remote: string;
41
+ /**
42
+ * Local name for the pulled plugin.
43
+ *
44
+ * The `:latest` tag is optional, and is used as the default if omitted.
45
+ */
46
+ readonly name?: string;
47
+ /**
48
+ * A base64url-encoded auth configuration to use when pulling a plugin from
49
+ * a registry.
50
+ *
51
+ * Refer to the [authentication section](#section/Authentication) for
52
+ * details.
53
+ */
54
+ readonly "X-Registry-Auth"?: string;
55
+ readonly body?: Array<PluginPrivilege>;
56
+ }
57
+ export interface PluginInspectOptions {
58
+ /**
59
+ * The name of the plugin. The `:latest` tag is optional, and is the default
60
+ * if omitted.
61
+ */
62
+ readonly name: string;
63
+ }
64
+ export interface PluginDeleteOptions {
65
+ /**
66
+ * The name of the plugin. The `:latest` tag is optional, and is the default
67
+ * if omitted.
68
+ */
69
+ readonly name: string;
70
+ /**
71
+ * Disable the plugin before removing. This may result in issues if the
72
+ * plugin is in use by a container.
73
+ */
74
+ readonly force?: boolean;
75
+ }
76
+ export interface PluginEnableOptions {
77
+ /**
78
+ * The name of the plugin. The `:latest` tag is optional, and is the default
79
+ * if omitted.
80
+ */
81
+ readonly name: string;
82
+ /** Set the HTTP client timeout (in seconds) */
83
+ readonly timeout?: number;
84
+ }
85
+ export interface PluginDisableOptions {
86
+ /**
87
+ * The name of the plugin. The `:latest` tag is optional, and is the default
88
+ * if omitted.
89
+ */
90
+ readonly name: string;
91
+ /** Force disable a plugin even if still in use. */
92
+ readonly force?: boolean;
93
+ }
94
+ export interface PluginUpgradeOptions {
95
+ /**
96
+ * The name of the plugin. The `:latest` tag is optional, and is the default
97
+ * if omitted.
98
+ */
99
+ readonly name: string;
100
+ /**
101
+ * Remote reference to upgrade to.
102
+ *
103
+ * The `:latest` tag is optional, and is used as the default if omitted.
104
+ */
105
+ readonly remote: string;
106
+ /**
107
+ * A base64url-encoded auth configuration to use when pulling a plugin from
108
+ * a registry.
109
+ *
110
+ * Refer to the [authentication section](#section/Authentication) for
111
+ * details.
112
+ */
113
+ readonly "X-Registry-Auth"?: string;
114
+ readonly body?: Array<PluginPrivilege>;
115
+ }
116
+ export interface PluginCreateOptions {
117
+ /**
118
+ * The name of the plugin. The `:latest` tag is optional, and is the default
119
+ * if omitted.
120
+ */
121
+ readonly name: string;
122
+ /** Path to tar containing plugin rootfs and manifest */
123
+ readonly tarContext: Stream.Stream<never, never, Uint8Array>;
124
+ }
125
+ export interface PluginPushOptions {
126
+ /**
127
+ * The name of the plugin. The `:latest` tag is optional, and is the default
128
+ * if omitted.
129
+ */
130
+ readonly name: string;
131
+ }
132
+ export interface PluginSetOptions {
133
+ /**
134
+ * The name of the plugin. The `:latest` tag is optional, and is the default
135
+ * if omitted.
136
+ */
137
+ readonly name: string;
138
+ readonly body?: Array<string>;
139
+ }
140
+ export interface Plugins {
141
+ /**
142
+ * List plugins
143
+ *
144
+ * @param filters - A JSON encoded value of the filters (a
145
+ * `map[string][]string`) to process on the plugin list.
146
+ *
147
+ * Available filters:
148
+ *
149
+ * - `capability=<capability name>`
150
+ * - `enable=<true>|<false>`
151
+ */
152
+ readonly list: (options?: PluginListOptions | undefined) => Effect.Effect<never, PluginsError, Readonly<Array<Plugin>>>;
153
+ /**
154
+ * Get plugin privileges
155
+ *
156
+ * @param remote - The name of the plugin. The `:latest` tag is optional,
157
+ * and is the default if omitted.
158
+ */
159
+ readonly getPrivileges: (options: GetPluginPrivilegesOptions) => Effect.Effect<never, PluginsError, Readonly<Array<PluginPrivilege>>>;
160
+ /**
161
+ * Install a plugin
162
+ *
163
+ * @param remote - Remote reference for plugin to install.
164
+ *
165
+ * The `:latest` tag is optional, and is used as the default if omitted.
166
+ * @param name - Local name for the pulled plugin.
167
+ *
168
+ * The `:latest` tag is optional, and is used as the default if omitted.
169
+ * @param X-Registry-Auth - A base64url-encoded auth configuration to use
170
+ * when pulling a plugin from a registry.
171
+ *
172
+ * Refer to the [authentication section](#section/Authentication) for
173
+ * details.
174
+ * @param body -
175
+ */
176
+ readonly pull: (options: PluginPullOptions) => Effect.Effect<never, PluginsError, void>;
177
+ /**
178
+ * Inspect a plugin
179
+ *
180
+ * @param name - The name of the plugin. The `:latest` tag is optional, and
181
+ * is the default if omitted.
182
+ */
183
+ readonly inspect: (options: PluginInspectOptions) => Effect.Effect<never, PluginsError, Readonly<Plugin>>;
184
+ /**
185
+ * Remove a plugin
186
+ *
187
+ * @param name - The name of the plugin. The `:latest` tag is optional, and
188
+ * is the default if omitted.
189
+ * @param force - Disable the plugin before removing. This may result in
190
+ * issues if the plugin is in use by a container.
191
+ */
192
+ readonly delete: (options: PluginDeleteOptions) => Effect.Effect<never, PluginsError, Readonly<Plugin>>;
193
+ /**
194
+ * Enable a plugin
195
+ *
196
+ * @param name - The name of the plugin. The `:latest` tag is optional, and
197
+ * is the default if omitted.
198
+ * @param timeout - Set the HTTP client timeout (in seconds)
199
+ */
200
+ readonly enable: (options: PluginEnableOptions) => Effect.Effect<never, PluginsError, void>;
201
+ /**
202
+ * Disable a plugin
203
+ *
204
+ * @param name - The name of the plugin. The `:latest` tag is optional, and
205
+ * is the default if omitted.
206
+ * @param force - Force disable a plugin even if still in use.
207
+ */
208
+ readonly disable: (options: PluginDisableOptions) => Effect.Effect<never, PluginsError, void>;
209
+ /**
210
+ * Upgrade a plugin
211
+ *
212
+ * @param name - The name of the plugin. The `:latest` tag is optional, and
213
+ * is the default if omitted.
214
+ * @param remote - Remote reference to upgrade to.
215
+ *
216
+ * The `:latest` tag is optional, and is used as the default if omitted.
217
+ * @param X-Registry-Auth - A base64url-encoded auth configuration to use
218
+ * when pulling a plugin from a registry.
219
+ *
220
+ * Refer to the [authentication section](#section/Authentication) for
221
+ * details.
222
+ * @param body -
223
+ */
224
+ readonly upgrade: (options: PluginUpgradeOptions) => Effect.Effect<never, PluginsError, void>;
225
+ /**
226
+ * Create a plugin
227
+ *
228
+ * @param name - The name of the plugin. The `:latest` tag is optional, and
229
+ * is the default if omitted.
230
+ * @param tarContext - Path to tar containing plugin rootfs and manifest
231
+ */
232
+ readonly create: (options: PluginCreateOptions) => Effect.Effect<never, PluginsError, void>;
233
+ /**
234
+ * Push a plugin
235
+ *
236
+ * @param name - The name of the plugin. The `:latest` tag is optional, and
237
+ * is the default if omitted.
238
+ */
239
+ readonly push: (options: PluginPushOptions) => Effect.Effect<never, PluginsError, void>;
240
+ /**
241
+ * Configure a plugin
242
+ *
243
+ * @param name - The name of the plugin. The `:latest` tag is optional, and
244
+ * is the default if omitted.
245
+ * @param body -
246
+ */
247
+ readonly set: (options: PluginSetOptions) => Effect.Effect<never, PluginsError, void>;
248
+ }
249
+ export declare const Plugins: Context.Tag<Plugins, Plugins>;
250
+ export declare const layer: Layer.Layer<IMobyConnectionAgent, never, Plugins>;
251
+ export declare const fromAgent: (agent: Effect.Effect<Scope.Scope, never, IMobyConnectionAgent>) => Layer.Layer<never, never, Plugins>;
252
+ export declare const fromConnectionOptions: (connectionOptions: MobyConnectionOptions) => Layer.Layer<never, never, Plugins>;
253
+ export {};
@@ -0,0 +1,47 @@
1
+ import * as NodeHttp from "@effect/platform-node/HttpClient";
2
+ import * as Schema from "@effect/schema/Schema";
3
+ import { Context, Data, Effect, Layer, pipe } from "effect";
4
+ import { MobyConnectionAgent, MobyHttpClientLive, getAgent, } from "./agent-helpers.js";
5
+ import { addQueryParameter, responseErrorHandler } from "./request-helpers.js";
6
+ import { Plugin, PluginPrivilege } from "./schemas.js";
7
+ export class PluginsError extends Data.TaggedError("PluginsError") {
8
+ }
9
+ const make = Effect.gen(function* (_) {
10
+ const agent = yield* _(MobyConnectionAgent);
11
+ const defaultClient = yield* _(NodeHttp.client.Client);
12
+ const client = defaultClient.pipe(NodeHttp.client.mapRequest(NodeHttp.request.prependUrl(`${agent.nodeRequestUrl}/plugins`)), NodeHttp.client.filterStatusOk);
13
+ const voidClient = client.pipe(NodeHttp.client.transform(Effect.asUnit));
14
+ const PluginClient = client.pipe(NodeHttp.client.mapEffect(NodeHttp.response.schemaBodyJson(Plugin)));
15
+ const PluginsClient = client.pipe(NodeHttp.client.mapEffect(NodeHttp.response.schemaBodyJson(Schema.array(Plugin))));
16
+ const PluginPrivilegesClient = client.pipe(NodeHttp.client.mapEffect(NodeHttp.response.schemaBodyJson(Schema.array(PluginPrivilege))));
17
+ const responseHandler = (method) => responseErrorHandler((message) => new PluginsError({ method, message }));
18
+ const list_ = (options) => pipe(NodeHttp.request.get(""), addQueryParameter("filters", options?.filters), PluginsClient, Effect.catchAll(responseHandler("list")));
19
+ const getPrivileges_ = (options) => pipe(NodeHttp.request.get("/privileges"), addQueryParameter("remote", options.remote), PluginPrivilegesClient, Effect.catchAll(responseHandler("getPrivileges")));
20
+ const pull_ = (options) => pipe(NodeHttp.request.post("/pull"), NodeHttp.request.setHeader("X-Registry-Auth", ""), addQueryParameter("remote", options.remote), addQueryParameter("name", options.name), NodeHttp.request.schemaBody(Schema.array(PluginPrivilege))(options.body ?? []), Effect.flatMap(voidClient), Effect.catchAll(responseHandler("pull")));
21
+ const inspect_ = (options) => pipe(NodeHttp.request.get("/{name}/json".replace("{name}", encodeURIComponent(options.name))), PluginClient, Effect.catchAll(responseHandler("inspect")));
22
+ const delete_ = (options) => pipe(NodeHttp.request.del("/{name}".replace("{name}", encodeURIComponent(options.name))), addQueryParameter("force", options.force), PluginClient, Effect.catchAll(responseHandler("delete")));
23
+ const enable_ = (options) => pipe(NodeHttp.request.post("/{name}/enable".replace("{name}", encodeURIComponent(options.name))), addQueryParameter("timeout", options.timeout), voidClient, Effect.catchAll(responseHandler("enable")));
24
+ const disable_ = (options) => pipe(NodeHttp.request.post("/{name}/disable".replace("{name}", encodeURIComponent(options.name))), addQueryParameter("force", options.force), voidClient, Effect.catchAll(responseHandler("disable")));
25
+ const upgrade_ = (options) => pipe(NodeHttp.request.post("/{name}/upgrade".replace("{name}", encodeURIComponent(options.name))), NodeHttp.request.setHeader("X-Registry-Auth", ""), addQueryParameter("remote", options.remote), NodeHttp.request.schemaBody(Schema.array(PluginPrivilege))(options.body ?? []), Effect.flatMap(voidClient), Effect.catchAll(responseHandler("upgrade")));
26
+ const create_ = (options) => pipe(NodeHttp.request.post("/create"), addQueryParameter("name", options.name), NodeHttp.request.streamBody(options.tarContext), voidClient, Effect.catchAll(responseHandler("create")));
27
+ const push_ = (options) => pipe(NodeHttp.request.post("/{name}/push".replace("{name}", encodeURIComponent(options.name))), voidClient, Effect.catchAll(responseHandler("push")));
28
+ const set_ = (options) => pipe(NodeHttp.request.post("/{name}/set".replace("{name}", encodeURIComponent(options.name))), NodeHttp.request.schemaBody(Schema.array(Schema.string))(options.body ?? []), Effect.flatMap(voidClient), Effect.catchAll(responseHandler("set")));
29
+ return {
30
+ list: list_,
31
+ getPrivileges: getPrivileges_,
32
+ pull: pull_,
33
+ inspect: inspect_,
34
+ delete: delete_,
35
+ enable: enable_,
36
+ disable: disable_,
37
+ upgrade: upgrade_,
38
+ create: create_,
39
+ push: push_,
40
+ set: set_,
41
+ };
42
+ });
43
+ export const Plugins = Context.Tag("the-moby-effect/Plugins");
44
+ export const layer = Layer.effect(Plugins, make).pipe(Layer.provide(MobyHttpClientLive));
45
+ export const fromAgent = (agent) => layer.pipe(Layer.provide(Layer.scoped(MobyConnectionAgent, agent)));
46
+ export const fromConnectionOptions = (connectionOptions) => fromAgent(getAgent(connectionOptions));
47
+ //# sourceMappingURL=plugins.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugins.js","sourceRoot":"","sources":["../../src/plugins.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,QAAQ,MAAM,kCAAkC,CAAC;AAC7D,OAAO,KAAK,MAAM,MAAM,uBAAuB,CAAC;AAChD,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAiB,IAAI,E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AS,GAAG,CAAC,KAA8D,EAAE,EAAE,CACxF,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,mBAAmB,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC;AAExE,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,iBAAwC,EAAE,EAAE,CAC9E,SAAS,CAAC,QAAQ,CAAC,iBAAiB,CAAC,CAAC,CAAC"}
@@ -0,0 +1,6 @@
1
+ import * as NodeHttp from "@effect/platform-node/HttpClient";
2
+ import * as ParseResult from "@effect/schema/ParseResult";
3
+ import { Effect, Stream } from "effect";
4
+ export declare const addQueryParameter: (key: string, value: unknown | unknown[] | undefined) => (self: NodeHttp.request.ClientRequest) => NodeHttp.request.ClientRequest;
5
+ export declare const responseErrorHandler: <E>(toError: (message: string) => E) => (error: NodeHttp.error.ResponseError | NodeHttp.error.RequestError | NodeHttp.body.BodyError | ParseResult.ParseError) => Effect.Effect<never, E, never>;
6
+ export declare const streamErrorHandler: <E>(toError: (message: string) => E) => (error: NodeHttp.error.ResponseError) => Stream.Stream<never, E, never>;
@@ -0,0 +1,15 @@
1
+ import * as NodeHttp from "@effect/platform-node/HttpClient";
2
+ import { Effect, Match, identity, pipe } from "effect";
3
+ export const addQueryParameter = (key, value) => value === undefined || (Array.isArray(value) && value.length === 0)
4
+ ? identity
5
+ : NodeHttp.request.setUrlParam(key, String(value));
6
+ export const responseErrorHandler = (toError) => (error) => pipe(error, Match.valueTags({
7
+ ParseError: (parseError) => Effect.fail(toError(`parsing errors\n${parseError.toString()}\n`)),
8
+ BodyError: (bodyError) => Effect.fail(toError(`body error ${bodyError.reason._tag}, ${String(bodyError.reason.error)}`)),
9
+ RequestError: (requestError) => Effect.fail(toError(`request error ${requestError.reason}, ${String(requestError.error)}`)),
10
+ ResponseError: (responseError) => responseError.response.text.pipe(Effect.catchTag("ResponseError", () => Effect.fail(toError(`response error ${responseError.reason}`))), Effect.flatMap((text) => Effect.fail(toError(`response error ${responseError.reason}, statusCode=${responseError.response.status} message=${text}`)))),
11
+ }));
12
+ export const streamErrorHandler = (toError) => (error) => pipe(error, Match.valueTags({
13
+ ResponseError: (responseError) => responseError.response.text.pipe(Effect.catchTag("ResponseError", () => Effect.fail(toError(`response error ${responseError.reason}`))), Effect.flatMap((text) => Effect.fail(toError(`response error ${responseError.reason}, statusCode=${responseError.response.status} message=${text}`)))),
14
+ }));
15
+ //# sourceMappingURL=request-helpers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"request-helpers.js","sourceRoot":"","sources":["../../src/request-helpers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,QAAQ,MAAM,kCAAkC,CAAC;AAE7D,OAAO,EAAE,MAAM,EAAE,KAAK,EAAU,QAAQ,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAE/D,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAC7B,GAAW,EACX,KAAsC,EACoC,EAAE,CAC5E,KAAK,KAAK,SAAS,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,CAAC;IAC/D,CAAC,CAAC,QAAQ;IACV,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,WAAW,CAAC,GAAG,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;AAE3D,MAAM,CAAC,MAAM,oBAAoB,GAC7B,CAAI,OAA+B,EAAE,EAAE,CACvC,CACI,KAI4B,EACE,EAAE,CAChC,IAAI,CACA,KAAK,EACL,KAAK,CAAC,SAAS,CAAC;IACZ,UAAU,EAAE,CAAC,UAAU,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,mBAAmB,UAAU,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;IAC9F,SAAS,EAAE,CAAC,SAAS,EAAE,EAAE,CACrB,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,cAAc,SAAS,CAAC,M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