@nosana/kit 1.0.3 → 1.0.8

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 (73) hide show
  1. package/dist/config/defaultConfigs.js +2 -0
  2. package/dist/config/types.d.ts +1 -0
  3. package/dist/generated_clients/merkle_distributor/accounts/claimStatus.d.ts +53 -0
  4. package/dist/generated_clients/merkle_distributor/accounts/claimStatus.js +65 -0
  5. package/dist/generated_clients/merkle_distributor/accounts/index.d.ts +9 -0
  6. package/dist/generated_clients/merkle_distributor/accounts/index.js +9 -0
  7. package/dist/generated_clients/merkle_distributor/accounts/merkleDistributor.d.ts +109 -0
  8. package/dist/generated_clients/merkle_distributor/accounts/merkleDistributor.js +93 -0
  9. package/dist/generated_clients/merkle_distributor/errors/index.d.ts +8 -0
  10. package/dist/generated_clients/merkle_distributor/errors/index.js +8 -0
  11. package/dist/generated_clients/merkle_distributor/errors/merkleDistributor.d.ts +63 -0
  12. package/dist/generated_clients/merkle_distributor/errors/merkleDistributor.js +89 -0
  13. package/dist/generated_clients/merkle_distributor/index.d.ts +11 -0
  14. package/dist/generated_clients/merkle_distributor/index.js +11 -0
  15. package/dist/generated_clients/merkle_distributor/instructions/claimLocked.d.ts +69 -0
  16. package/dist/generated_clients/merkle_distributor/instructions/claimLocked.js +84 -0
  17. package/dist/generated_clients/merkle_distributor/instructions/clawback.d.ts +69 -0
  18. package/dist/generated_clients/merkle_distributor/instructions/clawback.js +88 -0
  19. package/dist/generated_clients/merkle_distributor/instructions/closeClaimStatus.d.ts +45 -0
  20. package/dist/generated_clients/merkle_distributor/instructions/closeClaimStatus.js +73 -0
  21. package/dist/generated_clients/merkle_distributor/instructions/closeDistributor.d.ts +64 -0
  22. package/dist/generated_clients/merkle_distributor/instructions/closeDistributor.js +84 -0
  23. package/dist/generated_clients/merkle_distributor/instructions/index.d.ts +16 -0
  24. package/dist/generated_clients/merkle_distributor/instructions/index.js +16 -0
  25. package/dist/generated_clients/merkle_distributor/instructions/newClaim.d.ts +78 -0
  26. package/dist/generated_clients/merkle_distributor/instructions/newClaim.js +101 -0
  27. package/dist/generated_clients/merkle_distributor/instructions/newDistributor.d.ts +113 -0
  28. package/dist/generated_clients/merkle_distributor/instructions/newDistributor.js +122 -0
  29. package/dist/generated_clients/merkle_distributor/instructions/setAdmin.d.ts +48 -0
  30. package/dist/generated_clients/merkle_distributor/instructions/setAdmin.js +70 -0
  31. package/dist/generated_clients/merkle_distributor/instructions/setClawbackReceiver.d.ts +48 -0
  32. package/dist/generated_clients/merkle_distributor/instructions/setClawbackReceiver.js +76 -0
  33. package/dist/generated_clients/merkle_distributor/instructions/setEnableSlot.d.ts +47 -0
  34. package/dist/generated_clients/merkle_distributor/instructions/setEnableSlot.js +73 -0
  35. package/dist/generated_clients/merkle_distributor/programs/index.d.ts +8 -0
  36. package/dist/generated_clients/merkle_distributor/programs/index.js +8 -0
  37. package/dist/generated_clients/merkle_distributor/programs/merkleDistributor.d.ts +50 -0
  38. package/dist/generated_clients/merkle_distributor/programs/merkleDistributor.js +67 -0
  39. package/dist/generated_clients/merkle_distributor/shared/index.d.ts +49 -0
  40. package/dist/generated_clients/merkle_distributor/shared/index.js +86 -0
  41. package/dist/index.d.ts +5 -0
  42. package/dist/index.js +5 -0
  43. package/dist/programs/MerkleDistributorProgram.d.ts +101 -0
  44. package/dist/programs/MerkleDistributorProgram.js +296 -0
  45. package/package.json +19 -13
  46. package/.gitlab-ci.yml +0 -54
  47. package/.prettierignore +0 -17
  48. package/eslint.config.js +0 -47
  49. package/examples/browser/.gitlab-ci.yml +0 -78
  50. package/examples/browser/FEATURES.md +0 -141
  51. package/examples/browser/QUICK_START.md +0 -76
  52. package/examples/browser/README.md +0 -182
  53. package/examples/browser/app.vue +0 -1840
  54. package/examples/browser/assets/css/main.css +0 -7
  55. package/examples/browser/nuxt.config.ts +0 -30
  56. package/examples/browser/package-lock.json +0 -12230
  57. package/examples/browser/package.json +0 -31
  58. package/examples/browser/public/favicon.ico +0 -0
  59. package/examples/browser/public/robots.txt +0 -2
  60. package/examples/browser/start.sh +0 -38
  61. package/examples/browser/tailwind.config.js +0 -26
  62. package/examples/node/README.md +0 -261
  63. package/examples/node/example-keypair.json +0 -1
  64. package/examples/node/monitor.ts +0 -143
  65. package/examples/node/nos-service.ts +0 -117
  66. package/examples/node/package-lock.json +0 -589
  67. package/examples/node/package.json +0 -20
  68. package/examples/node/post-job.ts +0 -160
  69. package/examples/node/retrieve.ts +0 -18
  70. package/examples/node/set-wallet.ts +0 -87
  71. package/examples/node/stake-program.ts +0 -84
  72. package/scripts/generate-clients.ts +0 -22
  73. package/vitest.config.ts +0 -31
@@ -0,0 +1,296 @@
1
+ import { BaseProgram } from './BaseProgram.js';
2
+ import { parseBase64RpcAccount, address, } from 'gill';
3
+ import { NosanaError, ErrorCodes } from '../index.js';
4
+ import * as programClient from '../generated_clients/merkle_distributor/index.js';
5
+ import { convertBigIntToNumber } from '../utils/index.js';
6
+ import { findAssociatedTokenPda, TOKEN_PROGRAM_ADDRESS } from '@solana-program/token';
7
+ import bs58 from 'bs58';
8
+ import { SYSTEM_PROGRAM_ADDRESS } from 'gill/programs';
9
+ /**
10
+ * Claim target enum for merkle distributor.
11
+ * Determines which address receives the claimed tokens.
12
+ */
13
+ export var ClaimTarget;
14
+ (function (ClaimTarget) {
15
+ ClaimTarget["YES"] = "YES";
16
+ ClaimTarget["NO"] = "NO";
17
+ })(ClaimTarget || (ClaimTarget = {}));
18
+ /**
19
+ * Allowed addresses for receiving claimed tokens from merkle distributor.
20
+ * The `to` account must be the ATA of one of these addresses.
21
+ */
22
+ export const ALLOWED_RECEIVE_ADDRESSES = {
23
+ [ClaimTarget.YES]: address('YessuvqUauj9yW4B3eERcyRLWmQtWpFc2ERKmaedmCE'),
24
+ [ClaimTarget.NO]: address('NopXntmRdXhYNkoZaNTMUMShJ3aVG5RvwpiyPdd4bMh'),
25
+ };
26
+ /**
27
+ * Error thrown when a claim status account is not found
28
+ */
29
+ export class ClaimStatusNotFoundError extends Error {
30
+ constructor(address) {
31
+ super(`Claim status account not found at address ${address}`);
32
+ this.name = 'ClaimStatusNotFoundError';
33
+ }
34
+ }
35
+ export class MerkleDistributorProgram extends BaseProgram {
36
+ constructor(sdk) {
37
+ super(sdk);
38
+ this.client = programClient;
39
+ }
40
+ getProgramId() {
41
+ return this.sdk.config.programs.merkleDistributorAddress;
42
+ }
43
+ /**
44
+ * Derive the ClaimStatus PDA address for a given distributor and optional claimant.
45
+ * If claimant is not provided, uses the wallet's address.
46
+ *
47
+ * @param distributor The address of the merkle distributor
48
+ * @param claimant Optional claimant address. If not provided, uses the wallet's address.
49
+ * @returns The ClaimStatus PDA address
50
+ * @throws Error if wallet is not set and claimant is not provided
51
+ */
52
+ async getClaimStatusPda(distributor, claimant) {
53
+ let claimantAddress;
54
+ if (claimant) {
55
+ claimantAddress = claimant;
56
+ }
57
+ else {
58
+ if (!this.sdk.wallet) {
59
+ throw new Error('Wallet not set. Please set a wallet or provide a claimant address.');
60
+ }
61
+ claimantAddress = this.sdk.wallet.address;
62
+ }
63
+ return await this.sdk.solana.pda(['ClaimStatus', claimantAddress, distributor], this.getProgramId());
64
+ }
65
+ /**
66
+ * Fetch a merkle distributor account by address
67
+ */
68
+ async get(addr) {
69
+ try {
70
+ const distributorAccount = await this.client.fetchMerkleDistributor(this.sdk.solana.rpc, addr);
71
+ const distributor = this.transformMerkleDistributorAccount(distributorAccount);
72
+ return distributor;
73
+ }
74
+ catch (err) {
75
+ this.sdk.logger.error(`Failed to fetch merkle distributor ${err}`);
76
+ throw err;
77
+ }
78
+ }
79
+ /**
80
+ * Fetch all merkle distributor accounts
81
+ */
82
+ async all() {
83
+ try {
84
+ const getProgramAccountsResponse = await this.sdk.solana.rpc
85
+ .getProgramAccounts(this.getProgramId(), {
86
+ encoding: 'base64',
87
+ filters: [
88
+ {
89
+ memcmp: {
90
+ offset: BigInt(0),
91
+ bytes: bs58.encode(Buffer.from(this.client.MERKLE_DISTRIBUTOR_DISCRIMINATOR)),
92
+ encoding: 'base58',
93
+ },
94
+ },
95
+ ],
96
+ })
97
+ .send();
98
+ const distributors = getProgramAccountsResponse
99
+ .map((result) => {
100
+ try {
101
+ const distributorAccount = programClient.decodeMerkleDistributor(parseBase64RpcAccount(result.pubkey, result.account));
102
+ return this.transformMerkleDistributorAccount(distributorAccount);
103
+ }
104
+ catch (err) {
105
+ this.sdk.logger.error(`Failed to decode merkle distributor ${err}`);
106
+ return null;
107
+ }
108
+ })
109
+ .filter((account) => account !== null);
110
+ return distributors;
111
+ }
112
+ catch (err) {
113
+ this.sdk.logger.error(`Failed to fetch all merkle distributors ${err}`);
114
+ throw err;
115
+ }
116
+ }
117
+ /**
118
+ * Fetch a claim status account by address
119
+ */
120
+ async getClaimStatus(addr) {
121
+ try {
122
+ const maybeClaimStatus = await this.client.fetchMaybeClaimStatus(this.sdk.solana.rpc, addr);
123
+ // If account doesn't exist, throw a specific error
124
+ if (!maybeClaimStatus.exists) {
125
+ throw new ClaimStatusNotFoundError(addr);
126
+ }
127
+ // Transform and return the claim status
128
+ return this.transformClaimStatusAccount(maybeClaimStatus);
129
+ }
130
+ catch (err) {
131
+ this.sdk.logger.error(`Failed to fetch claim status ${err}`);
132
+ throw err;
133
+ }
134
+ }
135
+ /**
136
+ * Fetch claim status for a specific distributor and optional claimant.
137
+ * Derives the ClaimStatus PDA using the claimant address (or wallet's address if not provided) and the distributor address.
138
+ *
139
+ * @param distributor The address of the merkle distributor
140
+ * @param claimant Optional claimant address. If not provided, uses the wallet's address.
141
+ * @returns The claim status if it exists, null otherwise
142
+ * @throws Error if wallet is not set and claimant is not provided
143
+ */
144
+ async getClaimStatusForDistributor(distributor, claimant) {
145
+ try {
146
+ // Derive ClaimStatus PDA
147
+ const claimStatusPda = await this.getClaimStatusPda(distributor, claimant);
148
+ // Reuse getClaimStatus to fetch and transform the claim status
149
+ // If the account doesn't exist, it will throw, so we catch and return null
150
+ return await this.getClaimStatus(claimStatusPda);
151
+ }
152
+ catch (err) {
153
+ // If the account doesn't exist, return null instead of throwing
154
+ // Check if it's the specific ClaimStatusNotFoundError from getClaimStatus
155
+ if (err instanceof ClaimStatusNotFoundError) {
156
+ return null;
157
+ }
158
+ // For other errors, log and rethrow
159
+ this.sdk.logger.error(`Failed to fetch claim status ${err}`);
160
+ throw err;
161
+ }
162
+ }
163
+ /**
164
+ * Fetch all claim status accounts
165
+ * TODO: add filter for claimant and distributor
166
+ */
167
+ async allClaimStatus() {
168
+ try {
169
+ const getProgramAccountsResponse = await this.sdk.solana.rpc
170
+ .getProgramAccounts(this.getProgramId(), {
171
+ encoding: 'base64',
172
+ filters: [
173
+ {
174
+ memcmp: {
175
+ offset: BigInt(0),
176
+ bytes: bs58.encode(Buffer.from(this.client.CLAIM_STATUS_DISCRIMINATOR)),
177
+ encoding: 'base58',
178
+ },
179
+ },
180
+ ],
181
+ })
182
+ .send();
183
+ const claimStatuses = getProgramAccountsResponse
184
+ .map((result) => {
185
+ try {
186
+ const claimStatusAccount = programClient.decodeClaimStatus(parseBase64RpcAccount(result.pubkey, result.account));
187
+ return this.transformClaimStatusAccount(claimStatusAccount);
188
+ }
189
+ catch (err) {
190
+ this.sdk.logger.error(`Failed to decode claim status ${err}`);
191
+ return null;
192
+ }
193
+ })
194
+ .filter((account) => account !== null);
195
+ return claimStatuses;
196
+ }
197
+ catch (err) {
198
+ this.sdk.logger.error(`Failed to fetch all claim statuses ${err}`);
199
+ throw err;
200
+ }
201
+ }
202
+ /**
203
+ * Transform merkle distributor account to include address and convert BigInt to numbers
204
+ */
205
+ transformMerkleDistributorAccount(distributorAccount) {
206
+ const {
207
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
208
+ discriminator: _, root, buffer0, buffer1, buffer2, ...distributorAccountData } = distributorAccount.data;
209
+ const converted = convertBigIntToNumber(distributorAccountData);
210
+ return {
211
+ address: distributorAccount.address,
212
+ ...converted,
213
+ root: bs58.encode(Buffer.from(root)),
214
+ buffer0: bs58.encode(Buffer.from(buffer0)),
215
+ buffer1: bs58.encode(Buffer.from(buffer1)),
216
+ buffer2: bs58.encode(Buffer.from(buffer2)),
217
+ };
218
+ }
219
+ /**
220
+ * Transform claim status account to include address and convert BigInt to numbers
221
+ */
222
+ transformClaimStatusAccount(claimStatusAccount) {
223
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
224
+ const { discriminator: _, ...claimStatusAccountData } = claimStatusAccount.data;
225
+ return {
226
+ address: claimStatusAccount.address,
227
+ ...convertBigIntToNumber(claimStatusAccountData),
228
+ };
229
+ }
230
+ /**
231
+ * Claim tokens from a merkle distributor.
232
+ * This function creates a new ClaimStatus account and claims the tokens in a single instruction.
233
+ *
234
+ * @param params Parameters for claiming tokens
235
+ * @param params.claimant Optional claimant signer. If not provided, uses the wallet.
236
+ * @returns The newClaim instruction
237
+ * @throws NosanaError if tokens have already been claimed
238
+ * @throws Error if wallet is not set and claimant is not provided
239
+ */
240
+ async claim(params) {
241
+ // Determine claimant signer and address
242
+ let claimantSigner;
243
+ let claimantAddress;
244
+ if (params.claimant) {
245
+ claimantSigner = params.claimant;
246
+ claimantAddress = params.claimant.address;
247
+ }
248
+ else {
249
+ if (!this.sdk.wallet) {
250
+ throw new Error('Wallet not set. Please set a wallet or provide a claimant signer.');
251
+ }
252
+ claimantSigner = this.sdk.wallet;
253
+ claimantAddress = this.sdk.wallet.address;
254
+ }
255
+ try {
256
+ // Get the distributor account to find mint and tokenVault
257
+ const distributorAccount = await this.client.fetchMerkleDistributor(this.sdk.solana.rpc, params.distributor);
258
+ // Derive ClaimStatus PDA using the claimant address
259
+ const claimStatusPda = await this.getClaimStatusPda(params.distributor, claimantAddress);
260
+ // Check if ClaimStatus account exists
261
+ const maybeClaimStatus = await this.client.fetchMaybeClaimStatus(this.sdk.solana.rpc, claimStatusPda);
262
+ // If ClaimStatus already exists, throw an error (already claimed)
263
+ if (maybeClaimStatus.exists) {
264
+ throw new NosanaError('Tokens have already been claimed from this distributor', ErrorCodes.VALIDATION_ERROR);
265
+ }
266
+ // Get the target address for receiving tokens (YES or NO)
267
+ const targetAddress = ALLOWED_RECEIVE_ADDRESSES[params.target];
268
+ // Find the ATA of the target address (where tokens will be sent)
269
+ const [targetAta] = await findAssociatedTokenPda({
270
+ mint: distributorAccount.data.mint,
271
+ owner: targetAddress,
272
+ tokenProgram: TOKEN_PROGRAM_ADDRESS,
273
+ });
274
+ // Create newClaim instruction which creates the account and claims the tokens
275
+ // Note: tokens go to the ATA of the target address (YES or NO), not the claimant's ATA
276
+ // The claimant in the instruction is the claimant signer (or wallet if not provided)
277
+ const newClaimInstruction = programClient.getNewClaimInstruction({
278
+ distributor: params.distributor,
279
+ claimStatus: claimStatusPda,
280
+ from: distributorAccount.data.tokenVault,
281
+ to: targetAta, // ATA of YES or NO address, not claimant's ATA
282
+ claimant: claimantSigner, // Claimant signer (or wallet if not provided)
283
+ tokenProgram: TOKEN_PROGRAM_ADDRESS,
284
+ systemProgram: SYSTEM_PROGRAM_ADDRESS,
285
+ amountUnlocked: params.amountUnlocked,
286
+ amountLocked: params.amountLocked,
287
+ proof: params.proof,
288
+ }, { programAddress: this.getProgramId() });
289
+ return newClaimInstruction;
290
+ }
291
+ catch (err) {
292
+ this.sdk.logger.error(`Failed to create claim instructions: ${err}`);
293
+ throw err;
294
+ }
295
+ }
296
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nosana/kit",
3
- "version": "1.0.3",
3
+ "version": "1.0.8",
4
4
  "description": "Nosana KIT",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -13,8 +13,8 @@
13
13
  "generate-clients": "npx tsx scripts/generate-clients.ts",
14
14
  "lint": "eslint .",
15
15
  "lint:fix": "eslint . --fix",
16
- "format": "prettier --write \"**/*.ts\"",
17
- "prettier": "prettier --check \"**/*.ts\"",
16
+ "format": "prettier --check \"**/*.ts\"",
17
+ "format:fix": "prettier --write \"**/*.ts\"",
18
18
  "publish:public": "npm run build && npm publish --access public"
19
19
  },
20
20
  "keywords": [
@@ -27,12 +27,13 @@
27
27
  "author": "Nosana",
28
28
  "license": "MIT",
29
29
  "dependencies": {
30
- "@solana-program/token": "^0.5.1",
31
- "axios": "^1.6.0",
32
- "bs58": "^6.0.0",
33
- "buffer": "^6.0.3",
34
- "form-data": "^4.0.0",
35
- "gill": "^0.9.0"
30
+ "@solana-program/token": "0.5.1",
31
+ "@solana/sysvars": "5.0.0",
32
+ "axios": "1.6.0",
33
+ "bs58": "6.0.0",
34
+ "buffer": "6.0.3",
35
+ "form-data": "4.0.0",
36
+ "gill": "0.12.0"
36
37
  },
37
38
  "devDependencies": {
38
39
  "@codama/nodes-from-anchor": "^1.2.0",
@@ -40,15 +41,20 @@
40
41
  "@types/node": "^20.11.24",
41
42
  "@typescript-eslint/eslint-plugin": "^7.1.0",
42
43
  "@typescript-eslint/parser": "^7.1.0",
44
+ "@vitest/coverage-v8": "^1.6.0",
43
45
  "codama": "^1.3.0",
44
46
  "eslint": "^8.57.0",
45
- "vitest": "^1.6.0",
46
- "@vitest/coverage-v8": "^1.6.0",
47
47
  "prettier": "^3.2.5",
48
48
  "ts-node": "^10.9.2",
49
- "typescript": "^5.3.3"
49
+ "typescript": "^5.3.3",
50
+ "vitest": "^1.6.0"
50
51
  },
51
52
  "engines": {
52
53
  "node": ">=20.18.0"
53
- }
54
+ },
55
+ "files": [
56
+ "dist",
57
+ "package.json",
58
+ "README.md"
59
+ ]
54
60
  }
package/.gitlab-ci.yml DELETED
@@ -1,54 +0,0 @@
1
- # _ __ ___ ___ __ _ _ __ __ _
2
- # | '_ \ / _ \/ __|/ _` | '_ \ / _` |
3
- # | | | | (_) \__ \ (_| | | | | (_| |
4
- # |_| |_|\___/|___/\__,_|_| |_|\__,_|
5
-
6
- image: node:22.8.0
7
-
8
- include:
9
- - project: nosana-ci/tools/cicd/gitlab-ci
10
- file: templates/semver.yml
11
-
12
- npm prettier:
13
- stage: test
14
- script:
15
- - npm ci
16
- - npm run prettier
17
- rules:
18
- - if: $CI_MERGE_REQUEST_ID
19
- - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
20
-
21
- npm lint:
22
- stage: test
23
- script:
24
- - npm ci
25
- - npm run lint
26
- rules:
27
- - if: $CI_MERGE_REQUEST_ID
28
- - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
29
-
30
- npm test:
31
- stage: test
32
- script:
33
- - npm ci
34
- - npm test
35
- rules:
36
- - if: $CI_MERGE_REQUEST_ID
37
- - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
38
-
39
- release:
40
- stage: deploy
41
- extends: .release
42
- rules:
43
- - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
44
-
45
- npm publish prod:
46
- stage: deploy
47
- script:
48
- - sed -i "s/0.0.0/${CI_COMMIT_TAG:1}/" package.json
49
- - npm ci
50
- - npm config set '//registry.npmjs.org/:_authToken' "${NPM_TOKEN}"
51
- - npm run publish:public
52
- when: manual
53
- rules:
54
- - if: $CI_COMMIT_TAG && $CI_COMMIT_TAG != "latest"
package/.prettierignore DELETED
@@ -1,17 +0,0 @@
1
- # Generated code
2
- src/generated_clients/
3
-
4
- # Examples
5
- examples/
6
-
7
- # Build output
8
- dist/
9
- build/
10
-
11
- # Dependencies
12
- node_modules/
13
-
14
- # Coverage
15
- coverage/
16
- .nyc_output/
17
-
package/eslint.config.js DELETED
@@ -1,47 +0,0 @@
1
- import tseslint from '@typescript-eslint/eslint-plugin';
2
- import tsparser from '@typescript-eslint/parser';
3
-
4
- export default [
5
- {
6
- ignores: [
7
- 'dist/',
8
- 'node_modules/',
9
- 'coverage/',
10
- 'src/generated_clients/',
11
- 'examples/',
12
- '**/*.config.js',
13
- '**/*.config.ts',
14
- ],
15
- },
16
- {
17
- files: ['**/*.ts'],
18
- languageOptions: {
19
- parser: tsparser,
20
- parserOptions: {
21
- ecmaVersion: 2020,
22
- sourceType: 'module',
23
- },
24
- },
25
- plugins: {
26
- '@typescript-eslint': tseslint,
27
- },
28
- rules: {
29
- ...tseslint.configs.recommended.rules,
30
- '@typescript-eslint/explicit-function-return-type': 'off',
31
- '@typescript-eslint/no-explicit-any': 'warn',
32
- '@typescript-eslint/no-unused-vars': [
33
- 'error',
34
- { argsIgnorePattern: '^_' },
35
- ],
36
- 'no-console': ['warn', { allow: ['warn', 'error', 'debug', 'info'] }],
37
- },
38
- },
39
- {
40
- // More lenient rules for test files
41
- files: ['tests/**/*.ts', '**/*.test.ts', '**/*.spec.ts'],
42
- rules: {
43
- '@typescript-eslint/no-explicit-any': 'off'
44
- },
45
- },
46
- ];
47
-
@@ -1,78 +0,0 @@
1
- include:
2
- - project: nosana-ci/tools/cicd/gitlab-ci
3
- file: templates/semver.yml
4
- - project: nosana-ci/tools/cicd/gitlab-ci
5
- file: templates/cacheflush.yml
6
-
7
- variables:
8
- NODE_VERSION: 22
9
- OUTPUT_DIR: .output/public
10
- PURGE_FILE: purge.json
11
-
12
- .npm:
13
- image: node:$NODE_VERSION
14
- cache:
15
- key:
16
- files:
17
- - examples/browser/package-lock.json
18
- paths:
19
- - examples/browser/node_modules
20
- - examples/browser/.npm
21
-
22
- build:
23
- extends: .npm
24
- stage: build
25
- before_script:
26
- - cd examples/browser
27
- script: npm ci --cache .npm --prefer-offline
28
- rules:
29
- - if: $CI_MERGE_REQUEST_ID # merge requests
30
- - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH # main
31
- - if: $DEPLOYMENT_BRANCH && $CI_COMMIT_BRANCH == $DEPLOYMENT_BRANCH # optional deployment branch
32
-
33
- pages:
34
- extends: .npm
35
- stage: deploy
36
- before_script:
37
- - cd examples/browser
38
- script:
39
- - NODE_OPTIONS=--max_old_space_size=25384 npm run generate
40
- - |
41
- if [ -z ${SKIP_CACHEFLUSH} ] && [ -n ${FQDN} ]
42
- then
43
- apt update
44
- apt install -y jq
45
- find $OUTPUT_DIR -type f | sed "s/${OUTPUT_DIR//\//\\/}/https:\/\/$FQDN/g" | jq -R -s -c 'split("\n")[:-1]' > ../../$PURGE_FILE
46
- fi
47
- - mv $OUTPUT_DIR ../../public
48
- artifacts:
49
- paths:
50
- - public
51
- - $PURGE_FILE
52
- rules:
53
- - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH && $AUTO_DEPLOY != null # main
54
- - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH && $AUTO_DEPLOY == null # main
55
- when: manual
56
- - if: $DEPLOYMENT_BRANCH && $CI_COMMIT_BRANCH == $DEPLOYMENT_BRANCH && $AUTO_DEPLOY != null # deployment branch
57
- - if: $DEPLOYMENT_BRANCH && $CI_COMMIT_BRANCH == $DEPLOYMENT_BRANCH && $AUTO_DEPLOY == null # deployment branch
58
- when: manual
59
-
60
- release:
61
- extends: .release
62
- stage: .post
63
- rules:
64
- - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH # main
65
- - if: $DEPLOYMENT_BRANCH && $CI_COMMIT_BRANCH == $DEPLOYMENT_BRANCH # optional deployment branch
66
-
67
- gitlab-release:
68
- extends: .gitlab-release
69
- stage: .post
70
-
71
- cacheflush:
72
- extends: .cacheflush
73
- stage: .post
74
- rules:
75
- - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH # main
76
- - if: $DEPLOYMENT_BRANCH && $CI_COMMIT_BRANCH == $DEPLOYMENT_BRANCH # optional deployment branch
77
-
78
-