@xyo-network/sdk-js 2.102.5

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 (51) hide show
  1. package/LICENSE +165 -0
  2. package/README.md +94 -0
  3. package/dist/browser/index.cjs +26 -0
  4. package/dist/browser/index.cjs.map +1 -0
  5. package/dist/browser/index.d.cts +7 -0
  6. package/dist/browser/index.d.cts.map +1 -0
  7. package/dist/browser/index.d.mts +7 -0
  8. package/dist/browser/index.d.mts.map +1 -0
  9. package/dist/browser/index.d.ts +7 -0
  10. package/dist/browser/index.d.ts.map +1 -0
  11. package/dist/browser/index.js +8 -0
  12. package/dist/browser/index.js.map +1 -0
  13. package/dist/neutral/index.cjs +26 -0
  14. package/dist/neutral/index.cjs.map +1 -0
  15. package/dist/neutral/index.d.cts +7 -0
  16. package/dist/neutral/index.d.cts.map +1 -0
  17. package/dist/neutral/index.d.mts +7 -0
  18. package/dist/neutral/index.d.mts.map +1 -0
  19. package/dist/neutral/index.d.ts +7 -0
  20. package/dist/neutral/index.d.ts.map +1 -0
  21. package/dist/neutral/index.js +8 -0
  22. package/dist/neutral/index.js.map +1 -0
  23. package/dist/node/index.cjs +35 -0
  24. package/dist/node/index.cjs.map +1 -0
  25. package/dist/node/index.d.cts +7 -0
  26. package/dist/node/index.d.cts.map +1 -0
  27. package/dist/node/index.d.mts +7 -0
  28. package/dist/node/index.d.mts.map +1 -0
  29. package/dist/node/index.d.ts +7 -0
  30. package/dist/node/index.d.ts.map +1 -0
  31. package/dist/node/index.js +8 -0
  32. package/dist/node/index.js.map +1 -0
  33. package/docker/grafana/provisioning/dashboards/NodeJS Application Dashboard-11159.json +951 -0
  34. package/docker/grafana/provisioning/dashboards/Nodejs Metrics-11956.json +1759 -0
  35. package/docker/grafana/provisioning/dashboards/dashboard.yml +12 -0
  36. package/docker/grafana/provisioning/datasources/datasource.yml +11 -0
  37. package/docker/prometheus/prometheus.yml +14 -0
  38. package/docker-compose.metrics.yml +33 -0
  39. package/docker-compose.yml +62 -0
  40. package/jest.config.ts +31 -0
  41. package/jestSetup/globalSetup.ts +19 -0
  42. package/jestSetup/globalTeardown.ts +12 -0
  43. package/jestSetup/setupFiles.ts +10 -0
  44. package/package.json +126 -0
  45. package/scripts/clear-scrollback-buffer.sh +3 -0
  46. package/scripts/mongo/README.md +33 -0
  47. package/scripts/mongo/docker-entrypoint-initdb.d/00-create-key.sh +5 -0
  48. package/scripts/mongo/opt/mongo/joinReplicaSet.js +14 -0
  49. package/src/index.ts +7 -0
  50. package/test.log +11594 -0
  51. package/typedoc.json +14 -0
@@ -0,0 +1,12 @@
1
+ apiVersion: 1
2
+
3
+ providers:
4
+ - name: "Prometheus"
5
+ orgId: 1
6
+ folder: ""
7
+ type: file
8
+ disableDeletion: false
9
+ editable: true
10
+ allowUiUpdates: true
11
+ options:
12
+ path: /etc/grafana/provisioning/dashboards
@@ -0,0 +1,11 @@
1
+ apiVersion: 1
2
+
3
+ datasources:
4
+ - name: Prometheus
5
+ type: prometheus
6
+ access: proxy
7
+ orgId: 1
8
+ url: http://prometheus:9090
9
+ basicAuth: false
10
+ isDefault: true
11
+ editable: true
@@ -0,0 +1,14 @@
1
+ global:
2
+ scrape_interval: 15s
3
+ evaluation_interval: 15s
4
+
5
+ # Load and evaluate rules in this file every 'evaluation_interval' seconds.
6
+ rule_files:
7
+ - "alert.rules"
8
+
9
+ # A scrape configuration containing exactly one endpoint to scrape.
10
+ scrape_configs:
11
+ - job_name: "xyo"
12
+ scrape_interval: 10s
13
+ static_configs:
14
+ - targets: ["host.docker.internal:8080"]
@@ -0,0 +1,33 @@
1
+ version: "3.8"
2
+
3
+ services:
4
+ prometheus:
5
+ image: prom/prometheus:v2.37.6
6
+ container_name: prometheus
7
+ volumes:
8
+ - ./docker/prometheus:/etc/prometheus
9
+ - prometheus_data:/prometheus
10
+ command:
11
+ - "--config.file=/etc/prometheus/prometheus.yml"
12
+ - "--storage.tsdb.path=/prometheus"
13
+ - "--web.console.libraries=/etc/prometheus/console_libraries"
14
+ - "--web.console.templates=/etc/prometheus/consoles"
15
+ - "--storage.tsdb.retention.time=200h"
16
+ - "--web.enable-lifecycle"
17
+ restart: unless-stopped
18
+ ports:
19
+ - "9090:9090"
20
+
21
+ grafana:
22
+ image: grafana/grafana:9.4.3
23
+ container_name: grafana
24
+ volumes:
25
+ - grafana_data:/var/lib/grafana
26
+ - ./docker/grafana/provisioning:/etc/grafana/provisioning
27
+ environment:
28
+ - GF_SECURITY_ADMIN_USER=${ADMIN_USER:-admin}
29
+ - GF_SECURITY_ADMIN_PASSWORD=${ADMIN_PASSWORD:-admin}
30
+ - GF_USERS_ALLOW_SIGN_UP=false
31
+ restart: unless-stopped
32
+ ports:
33
+ - "3000:3000"
@@ -0,0 +1,62 @@
1
+ version: "3.8"
2
+
3
+ services:
4
+ mongo:
5
+ container_name: mongo
6
+ image: mongo:6.0.3
7
+ restart: always
8
+ ports:
9
+ - "27017:27017"
10
+ environment:
11
+ MONGO_INITDB_ROOT_USERNAME: root
12
+ MONGO_INITDB_ROOT_PASSWORD: example
13
+ MONGO_INITDB_DATABASE: archivist
14
+ healthcheck:
15
+ test:
16
+ [
17
+ "CMD",
18
+ "/usr/bin/mongosh",
19
+ "-u",
20
+ "root",
21
+ "-p",
22
+ "example",
23
+ "--quiet",
24
+ "/opt/mongo/joinReplicaSet.js",
25
+ ]
26
+ interval: 5s
27
+ timeout: 10s
28
+ retries: 3
29
+ start_period: 1s
30
+ volumes:
31
+ - ./scripts/mongo/opt/mongo:/opt/mongo
32
+ - ./scripts/mongo/docker-entrypoint-initdb.d:/docker-entrypoint-initdb.d
33
+ command:
34
+ [
35
+ "--auth",
36
+ "--bind_ip_all",
37
+ "--keyFile",
38
+ "/tmp/mongodb.key",
39
+ "--replSet",
40
+ "dbrs",
41
+ ]
42
+
43
+ # ipfs:
44
+ # image: ipfs/kubo:latest
45
+ # container_name: ipfs
46
+ # restart: unless-stopped
47
+ # environment:
48
+ # IPFS_PROFILE: server
49
+ # IPFS_PROFILE: default-networking
50
+ # IPFS_PROFILE: flatfs
51
+ # ports:
52
+ # - "4001:4001"
53
+ # - "5001:5001"
54
+ # - "8080:8080"
55
+ # ipfs-gateway:
56
+ # image: ipfs/bifrost-gateway:release
57
+ # container_name: ipfs-gateway
58
+ # restart: unless-stopped
59
+ # environment:
60
+ # PROXY_GATEWAY_URL: http://ipfs:8080
61
+ # ports:
62
+ # - "8081:8081"
package/jest.config.ts ADDED
@@ -0,0 +1,31 @@
1
+ const generateJestConfig = ({ esModules }: { esModules: string[] }) => {
2
+ const esModulesList = Array.isArray(esModules) ? esModules.join('|') : esModules
3
+ return {
4
+ coveragePathIgnorePatterns: ['<rootDir>/(.*)/dist'],
5
+ globalSetup: './jestSetup/globalSetup.ts',
6
+ globalTeardown: './jestSetup/globalTeardown.ts',
7
+ moduleNameMapper: {
8
+ '^(\\.{1,2}/.*)\\.js$': '$1',
9
+ },
10
+ preset: 'ts-jest/presets/default-esm',
11
+ setupFiles: ['dotenv/config'],
12
+ setupFilesAfterEnv: ['jest-sorted', 'jest-extended/all', './jestSetup/setupFiles.ts'],
13
+ testRegex: String.raw`(/__tests__/.*|(\.|/)((!perf\.)test|spec))\.tsx?$`,
14
+ testTimeout: 200_000,
15
+ transform: {
16
+ [`(${esModulesList}).+\\.js$`]: 'babel-jest',
17
+ '^.+\\.tsx?$': [
18
+ 'ts-jest',
19
+ {
20
+ tsconfig: 'tsconfig.test.json',
21
+ },
22
+ ],
23
+ },
24
+ transformIgnorePatterns: [`./node_modules/(?!${esModulesList})`],
25
+ }
26
+ }
27
+
28
+ const config = generateJestConfig({ esModules: ['is-ip', 'ip-regex', 'lodash-es', 'uuid', 'lodash-es', 'quick-lru'] })
29
+
30
+ // eslint-disable-next-line import/no-default-export
31
+ export default config
@@ -0,0 +1,19 @@
1
+ /* eslint-disable no-var */
2
+ import { config } from 'dotenv'
3
+ config()
4
+ import { Config } from 'jest'
5
+ import { SuperTest, Test } from 'supertest'
6
+
7
+ // Augment global scope with shared variables (must be var)
8
+ declare global {
9
+ var req: SuperTest<Test>
10
+ }
11
+
12
+ /**
13
+ * Jest global setup method runs before any tests are run
14
+ * https://jestjs.io/docs/configuration#globalsetup-string
15
+ */
16
+
17
+ const setup = async (_globalConfig: Config, _projectConfig: Config) => {}
18
+
19
+ module.exports = setup
@@ -0,0 +1,12 @@
1
+ import { config } from 'dotenv'
2
+ config()
3
+ import { Config } from 'jest'
4
+
5
+ /**
6
+ * Jest global teardown method runs after all tests are run
7
+ * https://jestjs.io/docs/configuration#globalteardown-string
8
+ */
9
+
10
+ const teardown = async (_globalConfig: Config, _projectConfig: Config) => {}
11
+
12
+ module.exports = teardown
@@ -0,0 +1,10 @@
1
+ import { ForgetPromise } from '@xylabs/forget'
2
+
3
+ beforeAll(() => {
4
+ // Can be async, before each test file
5
+ })
6
+
7
+ afterAll(async () => {
8
+ // Can be async, after each test file
9
+ await ForgetPromise.awaitInactive()
10
+ })
package/package.json ADDED
@@ -0,0 +1,126 @@
1
+ {
2
+ "author": {
3
+ "email": "support@xyo.network",
4
+ "name": "XYO Development Team",
5
+ "url": "https://xyo.network"
6
+ },
7
+ "bugs": {
8
+ "email": "support@xyo.network",
9
+ "url": "https://github.com/XYOracleNetwork/sdk-xyo-client-js/issues"
10
+ },
11
+ "workspaces": [
12
+ "packages/**/*"
13
+ ],
14
+ "dependencies": {
15
+ "@xyo-network/core-payload-plugins": "~2.102.5",
16
+ "@xyo-network/manifest": "~2.102.5",
17
+ "@xyo-network/modules": "~2.102.5",
18
+ "@xyo-network/protocol": "~2.102.5",
19
+ "@xyo-network/sdk-utils": "~2.102.5",
20
+ "@xyo-network/shared": "~2.102.5"
21
+ },
22
+ "description": "Primary SDK for using XYO Protocol 2.0",
23
+ "devDependencies": {
24
+ "@types/jest": "^29.5.12",
25
+ "@types/supertest": "^6.0.2",
26
+ "@xylabs/eslint-config": "^3.10.4",
27
+ "@xylabs/forget": "^3.3.3",
28
+ "@xylabs/ts-scripts-yarn3": "^3.10.4",
29
+ "@xylabs/tsconfig": "^3.10.4",
30
+ "@xylabs/tsconfig-dom-jest": "^3.10.4",
31
+ "dotenv": "^16.4.5",
32
+ "eslint": "^8.57.0",
33
+ "eslint-plugin-deprecation": "^2.0.0",
34
+ "jest": "^29.7.0",
35
+ "jest-docblock": "^29.7.0",
36
+ "jest-environment-jsdom": "^29.7.0",
37
+ "jest-extended": "^4.0.2",
38
+ "jest-runner": "^29.7.0",
39
+ "jest-runner-groups": "^2.2.0",
40
+ "jest-sorted": "^1.0.15",
41
+ "reflect-metadata": "^0.2.2",
42
+ "supertest": "^7.0.0",
43
+ "ts-jest": "^29.1.2",
44
+ "ts-node": "^10.9.2",
45
+ "typedoc": "^0.25.13",
46
+ "typedoc-material-theme": "^1.0.2",
47
+ "typescript": "^5.4.5"
48
+ },
49
+ "resolutions": {
50
+ "axios": "^1",
51
+ "bn.js": "^5",
52
+ "ethers": "6.11.0",
53
+ "fake-indexeddb": "^4",
54
+ "quick-lru": "^5"
55
+ },
56
+ "exports": {
57
+ ".": {
58
+ "browser": {
59
+ "require": {
60
+ "types": "./dist/browser/index.d.cts",
61
+ "default": "./dist/browser/index.cjs"
62
+ },
63
+ "import": {
64
+ "types": "./dist/browser/index.d.mts",
65
+ "default": "./dist/browser/index.js"
66
+ }
67
+ },
68
+ "node": {
69
+ "require": {
70
+ "types": "./dist/node/index.d.cts",
71
+ "default": "./dist/node/index.cjs"
72
+ },
73
+ "import": {
74
+ "types": "./dist/node/index.d.mts",
75
+ "default": "./dist/node/index.js"
76
+ }
77
+ }
78
+ },
79
+ "./package.json": "./package.json",
80
+ "./README.md": "./README.md"
81
+ },
82
+ "main": "./dist/node/index.cjs",
83
+ "module": "./dist/node/index.js",
84
+ "types": "./dist/node/index.d.cts",
85
+ "homepage": "https://xyo.network",
86
+ "license": "LGPL-3.0-only",
87
+ "name": "@xyo-network/sdk-js",
88
+ "publishConfig": {
89
+ "access": "public"
90
+ },
91
+ "repository": {
92
+ "type": "git",
93
+ "url": "https://github.com/XYOracleNetwork/sdk-xyo-client-js.git"
94
+ },
95
+ "scripts": {
96
+ "coverage": "yarn jest --coverage --forceExit",
97
+ "compile": "./scripts/clear-scrollback-buffer.sh && yarn xy compile",
98
+ "build": "xy build && xy statics",
99
+ "deploy": "xy deploy",
100
+ "lint-pkg": "npmPkgJsonLint .",
101
+ "perf": "yarn jest -c jest.config.perf.cjs",
102
+ "test-esm": "node $(yarn jest --no-cache --forceExit)",
103
+ "test": "jest --no-cache --forceExit",
104
+ "test:no-slow": "jest . --passWithNoTests --forceExit -- --group=-slow",
105
+ "test:module": "jest . --passWithNoTests --forceExit -- --group=module",
106
+ "test:sentinel": "jest . --passWithNoTests --forceExit -- --group=sentinel",
107
+ "test:thumbnail": "jest . --passWithNoTests --forceExit -- --group=thumbnail",
108
+ "test:no-mongo": "jest ${0} --passWithNoTests --forceExit -c ./jest.config.no-mongo.ts -- --group=-mongo",
109
+ "testx": "jest ${0} --passWithNoTests --forceExit -c ./jest.config.no-mongo.ts -- --group=-mongo",
110
+ "test:hash-perf": "jest packages/protocol/packages/core/packages/hash/src/spec/PayloadHasher.bigobj.perf.spec.ts -c ./jest.config.no-mongo.ts",
111
+ "test:hash-perf-parallel": "jest packages/protocol/packages/core/packages/hash/src/spec/PayloadHasher.bigobj-parallel.perf.spec.ts -c ./jest.config.no-mongo.ts",
112
+ "test:ci": "jest --runInBand --coverage --forceExit --passWithNoTests",
113
+ "free-8080": "kill -9 $(lsof -t -i :8080)",
114
+ "free-3033": "kill -9 $(lsof -t -i :3033)",
115
+ "free-mongo": "kill -9 $(lsof -t -i :55391) && kill -9 $(lsof -t -i :55393)",
116
+ "build-typedoc-site": "typedoc"
117
+ },
118
+ "sideEffects": false,
119
+ "version": "2.102.5",
120
+ "packageManager": "yarn@4.2.2",
121
+ "volta": {
122
+ "node": "20.12.0",
123
+ "yarn": "1.22.19"
124
+ },
125
+ "type": "module"
126
+ }
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env bash
2
+ clear
3
+ printf '\e[3J'
@@ -0,0 +1,33 @@
1
+ # MongoDB Scripts
2
+
3
+ The following scripts exist to initialize the local MongoDB instance
4
+ appropriately. From [their docs](https://hub.docker.com/_/mongo):
5
+
6
+ > When a container is started for the first time it will execute files with
7
+ > extensions `.sh` and `.js` that are found in `/docker-entrypoint-initdb.d`.
8
+ > Files will be executed in alphabetical order. `.js` files will be executed by
9
+ > mongo using the database specified by the `MONGO_INITDB_DATABASE` variable,
10
+ > if it is present, or test otherwise. You may also switch databases within the
11
+ > `.js` script.
12
+
13
+ It doesn't look like they support:
14
+
15
+ - `await`
16
+ - `console`
17
+
18
+ so be sure to code your scripts accordingly.
19
+
20
+ ## Debugging
21
+
22
+ For debugging with `mongosh` you can connect with something similar to the
23
+ following:
24
+
25
+ ```shell
26
+ mongosh --authenticationDatabase admin mongodb://root:example@localhost:27017/archivist
27
+ ```
28
+
29
+ From the mongo shell, to seed the DB with test data you can run:
30
+
31
+ ```shell
32
+ load('./scripts/mongo/test/seed.js')
33
+ ```
@@ -0,0 +1,5 @@
1
+ #!/bin/bash -eux
2
+
3
+ cd /tmp
4
+ openssl rand -base64 756 > mongodb.key
5
+ chmod 400 mongodb.key
@@ -0,0 +1,14 @@
1
+ /* eslint-disable no-undef */
2
+ const config = {
3
+ _id: 'dbrs',
4
+ members: [
5
+ {
6
+ _id: 0,
7
+ host: '127.0.0.1:27017',
8
+ priority: 1,
9
+ },
10
+ ],
11
+ version: 1,
12
+ }
13
+ rs.initiate(config, { force: true })
14
+ rs.status()
package/src/index.ts ADDED
@@ -0,0 +1,7 @@
1
+ /* eslint-disable no-restricted-imports */
2
+ export * from '@xyo-network/core-payload-plugins'
3
+ export * from '@xyo-network/manifest'
4
+ export * from '@xyo-network/modules'
5
+ export * from '@xyo-network/protocol'
6
+ export * from '@xyo-network/sdk-utils'
7
+ export * from '@xyo-network/shared'