@docstack/client 0.1.5 → 0.1.6

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 (77) hide show
  1. package/LICENSE +10 -0
  2. package/README.md +1 -1
  3. package/lib/core/attribute.d.ts +11 -2
  4. package/lib/core/class.d.ts +29 -6
  5. package/lib/core/content-transfer.d.ts +178 -0
  6. package/lib/core/crypto-engine/index.d.ts +82 -1
  7. package/lib/core/crypto-engine/utils.d.ts +36 -1
  8. package/lib/core/datamodel/index.d.ts +16 -0
  9. package/lib/core/domain.d.ts +1 -1
  10. package/lib/core/guarded-db.d.ts +52 -0
  11. package/lib/core/index.d.ts +106 -1
  12. package/lib/core/policy-engine/index.d.ts +35 -0
  13. package/lib/core/query-engine/classes.d.ts +24 -0
  14. package/lib/core/query-engine/executor.d.ts +11 -0
  15. package/lib/core/query-engine/index.d.ts +2 -1
  16. package/lib/core/query-engine/planner.d.ts +19 -0
  17. package/lib/core/stack.d.ts +676 -7
  18. package/lib/core/sync/class-filter.d.ts +106 -0
  19. package/lib/core/sync/filter-identity.d.ts +53 -0
  20. package/lib/core/sync/index.d.ts +334 -0
  21. package/lib/core/sync/internal-docs.d.ts +159 -0
  22. package/lib/index.d.ts +27 -1
  23. package/lib/index.js +4976 -607
  24. package/lib/index.umd.js +5004 -621
  25. package/lib/plugins/pouchdb.d.ts +43 -3
  26. package/lib/utils/logger/index.d.ts +28 -4
  27. package/lib/utils/logger/transport.d.ts +52 -11
  28. package/package.json +18 -10
  29. package/lib/core/attribute.js +0 -406
  30. package/lib/core/attribute.js.map +0 -1
  31. package/lib/core/class.js +0 -774
  32. package/lib/core/class.js.map +0 -1
  33. package/lib/core/crypto-engine/index.js +0 -229
  34. package/lib/core/crypto-engine/index.js.map +0 -1
  35. package/lib/core/crypto-engine/utils.js +0 -88
  36. package/lib/core/crypto-engine/utils.js.map +0 -1
  37. package/lib/core/datamodel/index.js +0 -1308
  38. package/lib/core/datamodel/index.js.map +0 -1
  39. package/lib/core/domain.js +0 -423
  40. package/lib/core/domain.js.map +0 -1
  41. package/lib/core/index.js +0 -532
  42. package/lib/core/index.js.map +0 -1
  43. package/lib/core/job-engine/index.js +0 -220
  44. package/lib/core/job-engine/index.js.map +0 -1
  45. package/lib/core/policy-engine/index.js +0 -232
  46. package/lib/core/policy-engine/index.js.map +0 -1
  47. package/lib/core/query-engine/accumulators.js +0 -258
  48. package/lib/core/query-engine/accumulators.js.map +0 -1
  49. package/lib/core/query-engine/evaluator.js +0 -179
  50. package/lib/core/query-engine/evaluator.js.map +0 -1
  51. package/lib/core/query-engine/executor.js +0 -405
  52. package/lib/core/query-engine/executor.js.map +0 -1
  53. package/lib/core/query-engine/index.js +0 -4
  54. package/lib/core/query-engine/index.js.map +0 -1
  55. package/lib/core/query-engine/parser.js +0 -515
  56. package/lib/core/query-engine/parser.js.map +0 -1
  57. package/lib/core/query-engine/planner.js +0 -330
  58. package/lib/core/query-engine/planner.js.map +0 -1
  59. package/lib/core/stack.js +0 -1827
  60. package/lib/core/stack.js.map +0 -1
  61. package/lib/core/test-utils/docstack.js +0 -222
  62. package/lib/core/test-utils/docstack.js.map +0 -1
  63. package/lib/core/trigger/index.js +0 -81
  64. package/lib/core/trigger/index.js.map +0 -1
  65. package/lib/index.js.map +0 -1
  66. package/lib/plugins/pouchdb.js +0 -412
  67. package/lib/plugins/pouchdb.js.map +0 -1
  68. package/lib/utils/crypto/index.js +0 -34
  69. package/lib/utils/crypto/index.js.map +0 -1
  70. package/lib/utils/index.js +0 -58
  71. package/lib/utils/index.js.map +0 -1
  72. package/lib/utils/logger/index.js +0 -20
  73. package/lib/utils/logger/index.js.map +0 -1
  74. package/lib/utils/logger/transport.js +0 -28
  75. package/lib/utils/logger/transport.js.map +0 -1
  76. package/lib/workers/dataModel.js +0 -48
  77. package/lib/workers/dataModel.js.map +0 -1
package/lib/core/index.js DELETED
@@ -1,532 +0,0 @@
1
- // import express, {Express} from 'express'
2
- // import { static as exStatic } from 'express';
3
- // import * as dotenv from "dotenv";
4
- // import cors from "cors";
5
- // dotenv.config({ path: './.env' })
6
- import createlogger from "../utils/logger/index.js";
7
- // import test from '../../../server/src//utils/dbManager/test';
8
- // import { generateJwtKeys, generatePswKeys } from '../../../server/src/utils/crypto';
9
- import ClientStack from './stack.js';
10
- // import { login, JWTAuthPayload, setupAdminUser } from '../../../server/src//utils/auth';
11
- // import memoryAdapter from "pouchdb-adapter-memory"
12
- // import cookieParser from 'cookie-parser';
13
- // import jwt from 'jsonwebtoken';
14
- import Class from "./class.js";
15
- import Domain from './domain.js';
16
- import { Trigger } from "./trigger/index.js";
17
- import { JobEngine } from "./job-engine/index.js";
18
- // import AbstractClass from '../../shared/src//utils/stack/class';
19
- import Attribute from './attribute.js';
20
- // import { EventTarget } from 'node:events';
21
- // let envPath = process.env.ENVFILE || "./.env";
22
- // envPath = resolve(process.cwd(), envPath);
23
- // dotenv.config({ path: envPath });
24
- // [TODO] Implement DocStack.type in "remote" | "local"
25
- // When is remote, open a websocket (socket.io) connection to given remote
26
- // implement cases in each of stack methods (queries and doc creation)
27
- // to actually send and receive messages
28
- // [TODO][HARD] Think about authentication mechanism
29
- // Probably support same rest authentication (jwtToken)
30
- // but also api tokens
31
- // Remote connection that require auth can be opened but
32
- // cannot send or receive messages until authentication
33
- /**
34
- * The main entry point for the DocStack client library.
35
- *
36
- * DocStack manages multiple {@link ClientStack} instances and provides
37
- * a unified interface for database operations, authentication, and
38
- * class/attribute creation.
39
- *
40
- * The client emits a `ready` event when all stacks are initialized.
41
- *
42
- * @example
43
- * ```typescript
44
- * // Initialize DocStack with a single database
45
- * const docstack = new DocStack({ name: 'my-app' });
46
- *
47
- * // Wait for ready
48
- * docstack.addEventListener('ready', async () => {
49
- * const stack = docstack.getStack('my-app');
50
- * const taskClass = await stack.getClass('Task');
51
- * });
52
- *
53
- * // Initialize with credentials for automatic authentication
54
- * const docstack = new DocStack({
55
- * name: 'my-app',
56
- * credentials: { username: 'admin', password: 'secret' }
57
- * });
58
- * ```
59
- *
60
- * @extends EventTarget
61
- */
62
- class DocStack extends EventTarget {
63
- async addStack(config) {
64
- let stack;
65
- if (typeof config == "object" && config.name) {
66
- stack = await ClientStack.create(`db-${config.name}`, {
67
- // defaults to leveldb
68
- // adapter: 'memory',
69
- plugins: [
70
- // https://www.npmjs.com/package/pouchdb-adapter-memory
71
- // memoryAdapter
72
- ],
73
- patches: config.patches,
74
- credentials: config.credentials,
75
- disableCryptoEngine: config.disableCryptoEngine,
76
- });
77
- }
78
- else if (typeof config === "string") {
79
- stack = await ClientStack.create(`db-${config}`, {
80
- // defaults to leveldb
81
- // adapter: 'memory',
82
- plugins: [
83
- // https://www.npmjs.com/package/pouchdb-adapter-memory
84
- // memoryAdapter
85
- ]
86
- });
87
- }
88
- if (stack) {
89
- this.stacks.push(stack);
90
- // let window_ = window as Window & typeof globalThis & {
91
- // stacks: ClientStack[]
92
- // }
93
- // if (window_.stacks) {
94
- // window_.stacks.push(stack)
95
- // }
96
- return stack;
97
- }
98
- // await setupAdminUser();
99
- }
100
- /**
101
- * Resets all initialized stacks.
102
- * This clears the data in all stacks managed by this DocStack instance.
103
- *
104
- * @throws Error if the reset operation fails for any stack.
105
- */
106
- async resetAll() {
107
- try {
108
- for (const stack of this.stacks) {
109
- await stack.reset();
110
- }
111
- }
112
- catch (e) {
113
- throw new Error(e);
114
- }
115
- }
116
- /**
117
- * Returns all initialized stacks.
118
- * @returns Array of ClientStack instances
119
- */
120
- getStacks() {
121
- return this.stacks;
122
- }
123
- /**
124
- * Authenticates a user on a specific stack.
125
- *
126
- * @param name - The stack name to authenticate against
127
- * @param credentials - The user's login credentials
128
- * @returns The authentication session proof
129
- * @throws Error if the stack is not found
130
- *
131
- * @example
132
- * ```typescript
133
- * const proof = await docstack.authenticateStack('my-app', {
134
- * username: 'user@example.com',
135
- * password: 'password123'
136
- * });
137
- * ```
138
- */
139
- async authenticateStack(name, credentials) {
140
- const stack = this.getStack(name);
141
- if (!stack) {
142
- throw new Error(`Stack '${name}' not found`);
143
- }
144
- return stack.authenticate(credentials);
145
- }
146
- /**
147
- * Returns whether all stacks have been initialized.
148
- * @returns `true` if ready, `false` otherwise
149
- */
150
- getReadyState() {
151
- return this.readyState;
152
- }
153
- /**
154
- * Resets all stacks and re-initializes them.
155
- * Useful for testing or clearing all data.
156
- */
157
- async reset() {
158
- try {
159
- await this.resetAll();
160
- await this.initStacks(this.config);
161
- }
162
- catch (e) {
163
- throw new Error(e);
164
- }
165
- }
166
- /**
167
- * Creates a new DocStack client instance.
168
- * Initializes all configured stacks asynchronously.
169
- * Listen for the `ready` event to know when initialization is complete.
170
- *
171
- * @param config - One or more stack configurations
172
- *
173
- * @example
174
- * ```typescript
175
- * const docstack = new DocStack(
176
- * { name: 'primary-db' },
177
- * { name: 'backup-db' }
178
- * );
179
- *
180
- * docstack.addEventListener('ready', () => {
181
- * console.log('All stacks ready!');
182
- * });
183
- * ```
184
- */
185
- constructor(...config) {
186
- super();
187
- /** Array of stack configurations used for initialization. */
188
- this.config = [];
189
- /** Array of all initialized ClientStack instances. */
190
- this.stacks = [];
191
- this.logger = createlogger().child({ module: "client" });
192
- this.initStacks = async (configs) => {
193
- // TODO: Consider changing to Promise.all for concurrency
194
- for (const config of configs) {
195
- const stack = await this.addStack(config);
196
- }
197
- this.readyState = true;
198
- this.dispatchEvent(new CustomEvent("ready", {
199
- detail: {
200
- stacks: this.stacks
201
- }
202
- }));
203
- };
204
- /**
205
- * Gets a stack by its name or connection string.
206
- *
207
- * @param name - The stack name or connection identifier
208
- * @returns The matching ClientStack, or `undefined` if not found
209
- *
210
- * @example
211
- * ```typescript
212
- * const stack = docstack.getStack('my-app');
213
- * if (stack) {
214
- * const users = await stack.query('SELECT * FROM User');
215
- * }
216
- * ```
217
- */
218
- this.getStack = (name) => {
219
- return this.stacks.find(s => s.name == name || s.connection == name);
220
- };
221
- /**
222
- * Clears the connection data for a specific stack connection string.
223
- *
224
- * @param conn - The connection string or name to clear.
225
- * @throws Error if the connection name is missing or the operation fails.
226
- */
227
- this.clearConnection = async (conn) => {
228
- const fnLogger = this.logger.child({ method: 'clearConnection' });
229
- try {
230
- // const conn = req.params.conn;
231
- if (!conn) {
232
- throw new Error("Connection name not provided");
233
- }
234
- await ClientStack.clear(conn);
235
- fnLogger.info('Internal database cleared');
236
- // return res.status(200).json({ success: true, message: 'Internal database cleared' });
237
- }
238
- catch (e) {
239
- throw new Error(e);
240
- // return res.status(500).json({ success: false, error: 'An error occurred' });
241
- }
242
- };
243
- /**
244
- * Exports all documents from a stack.
245
- *
246
- * @param stackName - The name of the stack to export
247
- * @returns All documents from the stack
248
- * @throws Error if the stack is not found
249
- */
250
- this.export = async (stackName) => {
251
- const stack = this.getStack(stackName);
252
- if (stack) {
253
- const dump = await stack.dump();
254
- return dump;
255
- }
256
- else {
257
- throw new Error(`Did not find any stack for name '${stackName}'`);
258
- }
259
- };
260
- /**
261
- * Creates a new Class in the specified stack.
262
- *
263
- * @param stackName - The name of the stack to create the class in
264
- * @param name - The class name
265
- * @param config - Configuration with type and description
266
- * @throws Error if the stack is not found
267
- *
268
- * @example
269
- * ```typescript
270
- * await docstack.createClass('my-app', 'Product', {
271
- * type: 'class',
272
- * description: 'Product catalog items'
273
- * });
274
- * ```
275
- */
276
- this.createClass = async (stackName, name, config) => {
277
- const fnLogger = this.logger.child({ method: 'createClass' });
278
- const stack = this.getStack(stackName);
279
- if (!stack) {
280
- throw new Error(`Stack '${stackName}' not found`);
281
- }
282
- const { type, description } = config;
283
- fnLogger.info("Args", {
284
- stackName, name, config
285
- });
286
- try {
287
- const newClass = await Class.create(stack, name, "class", description, {});
288
- fnLogger.info(`class '${name}' created successfully.`, { classModel: newClass.getModel() });
289
- }
290
- catch (e) {
291
- throw new Error(`Error during class '${name}' creation. ${e}`);
292
- }
293
- fnLogger.info('Class created successfully');
294
- };
295
- /**
296
- * Creates a new Attribute on a Class in the specified stack.
297
- *
298
- * @param stackName - The name of the stack containing the class
299
- * @param className - The class to add the attribute to
300
- * @param params - Attribute configuration
301
- * @throws Error if the stack or class is not found
302
- *
303
- * @example
304
- * ```typescript
305
- * await docstack.createAttribute('my-app', 'Product', {
306
- * name: 'price',
307
- * type: 'number',
308
- * description: 'Product price in cents'
309
- * });
310
- * ```
311
- */
312
- this.createAttribute = async (stackName, className, params) => {
313
- const fnLogger = this.logger.child({ method: 'createAttribute' });
314
- const stack = this.getStack(stackName);
315
- if (!stack) {
316
- throw new Error(`Stack '${stackName}' not found`);
317
- }
318
- const { name, type, description, config } = params;
319
- fnLogger.info(`Creating attribute for class '${className}' in stack '${stackName}'`, {
320
- name, type, config
321
- });
322
- try {
323
- // Loads the class object
324
- let classObj = await stack.getClass(className);
325
- if (classObj) {
326
- let newAttribute = await Attribute.create(classObj, name, type, description, config);
327
- fnLogger.info(`Attribute '${name}' added to class '${className}'`, { attributeModel: newAttribute.getModel() });
328
- }
329
- else {
330
- throw new Error(`Failed to retrieve Class '${className}'`);
331
- }
332
- }
333
- catch (e) {
334
- fnLogger.error(`Error during attribute '${name}' creation: ${e}`);
335
- throw new Error(`Error during attribute '${name}' creation: ${e}`);
336
- }
337
- };
338
- this.readyState = false;
339
- const fnLogger = this.logger.child({ method: "constructor" });
340
- /*
341
- this.app.use(logRequest)
342
- // Enable CORS for all routes
343
- if (process.env.NODE_ENV === 'development') {
344
- logger.info("Development environment. Enabling CORS for :8080");
345
- this.app.use(cors({
346
- origin: 'http://localhost:8080',
347
- // Replace with the origin of webpack dev server
348
- methods: ['GET', 'POST'],
349
- credentials: true,
350
- }));
351
- }
352
- */
353
- /*
354
- // Use built-in middleware for parsing JSON and URL-encoded data
355
- this.app.use(express.json());
356
- this.app.use(express.urlencoded({ extended: true }));
357
- this.app.use(cookieParser());
358
- this.app.use((req, res, next) => {
359
- if (!this.readyState) {
360
- return res.status(503); // Service Unavailable.
361
- }
362
- // Server is ready to receive requests
363
- next()
364
- })
365
- */
366
- /*
367
- this.app.use('/api/private', (req, res, next) => {
368
- const token = req.cookies.jwtToken
369
- if (!token) {
370
- logger.error("No token provided")
371
- return res.status(403).json({
372
- success: false,
373
- message: 'No token provided',
374
- });
375
- }
376
- const secretKey = process.env.JWT_PUBLIC_KEY;
377
- if (!secretKey || secretKey === '') {
378
- logger.error("No secret key found")
379
- return res.status(500).json({
380
- success: false,
381
- message: 'No secret key found',
382
- });
383
- }
384
- jwt.verify(token, secretKey, async (err, payload: JWTAuthPayload) => {
385
- if (err) {
386
- logger.error("Invalid token", err)
387
- return res.status(403).json({
388
- success: false,
389
- message: 'Invalid token',
390
- });
391
- } else {
392
- // Check whether the session is still valid
393
- const { sessionId } = payload;
394
- const UserSessionClass = await this.store.getClass("UserSession");
395
- const sessionCards = await UserSessionClass.getCards({
396
- sessionId: { $eq: sessionId },
397
- sessionStatus: { $eq: "active" }
398
- }, null, 0, 1);
399
- if (sessionCards.length === 0) {
400
- return res.status(403).json({
401
- success: false,
402
- message: 'Session expired',
403
- });
404
- }
405
- // TODO: Consider passing the session card to the next middleware
406
- next();
407
- }
408
- });
409
- })
410
- */
411
- // TODO: Serve the dashboard to a specific route, i.e.: admin
412
- // this.app.use(exStatic('./dist'));
413
- // TODO: Serve the static files from the build folder
414
- // of the UI application
415
- // this.app.get('*', (req, res) => {
416
- // const templatePath = resolve(__dirname, './dist', 'index.html');
417
- // res.sendFile(templatePath);
418
- // });
419
- /*
420
- this.app.post('/login', async (req, res) => {
421
- try {
422
- const { username, password } = req.body;
423
- const { responseCode, body, token } = await login(username, password);
424
- // Append also the token to the response
425
- let cookieOptions = {}
426
- if (process.env.NODE_ENV === 'development') {
427
- cookieOptions = { sameSite: 'None', secure: true, maxAge: 1000 * 60 * 15 };
428
- logger.warn("Development mode: setting cookie options to SameSite=None; Secure=true for JWT token");
429
- } else cookieOptions = { sameSite: 'Strict', httpOnly: true, maxAge: 1000 * 60 * 15 };
430
-
431
- res.cookie('jwtToken', token, cookieOptions);
432
- return res.status(responseCode).json(body);
433
- } catch (error) {
434
- console.error("Error during login", error);
435
- return res.status(500).json({ success: false, error: 'An error occurred' });
436
- }
437
- });
438
- */
439
- /*
440
- this.app.get('/api/private/reset', async (req, res) => {
441
- try {
442
- await this.reset();
443
- return res.status(200).json({ success: true, message: 'Internal database reset' });
444
- } catch (e) {
445
- return res.status(500).json({ success: false, error: 'An error occurred' });
446
- }
447
- });
448
- */
449
- /*
450
- this.app.get('/api/private/clear:conn', async (req, res) => {
451
- try {
452
- const conn = req.params.conn;
453
- if (!conn) {
454
- throw new Error("Connection name not provided");
455
- }
456
- await ClientStack.clear(conn);
457
- return res.status(200).json({ success: true, message: 'Internal database cleared' });
458
- } catch (e) {
459
- logger.error("Error during database clear", e);
460
- return res.status(500).json({ success: false, error: 'An error occurred' });
461
- }
462
- });
463
- */
464
- /*
465
- this.app.get('/api/private/test', (req, res) => {
466
- return res.status(200).json({ message: 'Hello from the server! This is a private route' });
467
- });
468
- */
469
- /*
470
- this.app.post('/api/private/create-class/:name', async (req, res) => {
471
- const { name } = req.params;
472
- const { type, description } = req.query;
473
- logger.info("create-class - received request", {
474
- params: req.params,
475
- query: req.query
476
- })
477
-
478
- try {
479
- const newClass = await Class.create(
480
- this.store, name, type as string, description as string
481
- );
482
- logger.info("create-class", `class '${name}' created successfully.`,
483
- {classModel: newClass.getModel()}
484
- )
485
- } catch (e) {
486
- logger.error(`Error during class '${name} creation: ${e}`);
487
- return res.status(500).json({ success: false, error: 'An error occurred' });
488
- }
489
-
490
- return res.status(200).json({ success: true, message: 'Class created successfully' });
491
- })
492
- */
493
- /*
494
- this.app.put('/api/private/create-attribute/:name', async (req, res) => {
495
- const className = req.params.name;
496
- const { name, type, config } = req.body;
497
- logger.info(`create-attribute - for class '${className}'`, {
498
- name, type, config
499
- });
500
-
501
- try {
502
- // Loads the class object
503
- let classObj = await this.store.getClass(className);
504
- let newAttribute = await Attribute.create(classObj, name, type, config);
505
- logger.info(`create-attribute - Attribute '${name}' added to class '${className}'`,
506
- {attributeModel: newAttribute.getModel()}
507
- );
508
- } catch (e) {
509
- logger.error(`Error during attribute '${name}' creation: ${e}`)
510
- }
511
- })
512
- */
513
- // const port = process.env.SERVER_PORT || 5000;
514
- // const server = this.app.listen(port, () => logger.info(`Listening on port ${port}`));
515
- // Procedure that should run once only
516
- // can be considered "setup procedures"
517
- //generatePswKeys()
518
- // generateJwtKeys()
519
- // Server "startup procedures"
520
- // setTimeout(test, 1000)
521
- this.initStacks(config);
522
- this.addEventListener("ready", () => fnLogger.info("DocStack client successfully initialized"));
523
- }
524
- }
525
- /**
526
- * Core exports from the DocStack client library.
527
- *
528
- * @module @docstack/client
529
- */
530
- export { ClientStack, Trigger, Class, Attribute, Domain, JobEngine };
531
- export { DocStack };
532
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AAAA,2CAA2C;AAC3C,gDAAgD;AAChD,oCAAoC;AACpC,2BAA2B;AAC3B,oCAAoC;AACpC,OAAO,YAAY,MAAM,0BAA0B,CAAA;AACnD,gEAAgE;AAChE,uFAAuF;AACvF,OAAO,WAAW,MAAM,YAAY,CAAC;AACrC,2FAA2F;AAC3F,qDAAqD;AACrD,4CAA4C;AAC5C,kCAAkC;AAClC,OAAO,KAAK,MAAM,YAAY,CAAC;AAC/B,OAAO,MAAM,MAAM,aAAa,CAAC;AACjC,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAClD,mEAAmE;AACnE,OAAO,SAAS,MAAM,gBAAgB,CAAC;AAGvC,6CAA6C;AAE7C,iDAAiD;AACjD,6CAA6C;AAC7C,oCAAoC;AAGpC,uDAAuD;AACvD,0EAA0E;AAC1E,sEAAsE;AACtE,wCAAwC;AACxC,oDAAoD;AACpD,uDAAuD;AACvD,sBAAsB;AACtB,wDAAwD;AACxD,uDAAuD;AACvD;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4B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