@offnominal/ndb2-api-types 0.2.2

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 (41) hide show
  1. package/README.md +28 -0
  2. package/dist/v2/endpoints/index.d.ts +3 -0
  3. package/dist/v2/endpoints/index.js +41 -0
  4. package/dist/v2/endpoints/index.js.map +1 -0
  5. package/dist/v2/endpoints/predictions.d.ts +10 -0
  6. package/dist/v2/endpoints/predictions.js +3 -0
  7. package/dist/v2/endpoints/predictions.js.map +1 -0
  8. package/dist/v2/endpoints/seasons.d.ts +6 -0
  9. package/dist/v2/endpoints/seasons.js +3 -0
  10. package/dist/v2/endpoints/seasons.js.map +1 -0
  11. package/dist/v2/entities/index.d.ts +3 -0
  12. package/dist/v2/entities/index.js +41 -0
  13. package/dist/v2/entities/index.js.map +1 -0
  14. package/dist/v2/entities/predictions.d.ts +65 -0
  15. package/dist/v2/entities/predictions.js +3 -0
  16. package/dist/v2/entities/predictions.js.map +1 -0
  17. package/dist/v2/entities/seasons.d.ts +10 -0
  18. package/dist/v2/entities/seasons.js +3 -0
  19. package/dist/v2/entities/seasons.js.map +1 -0
  20. package/dist/v2/errors.d.ts +12 -0
  21. package/dist/v2/errors.js +34 -0
  22. package/dist/v2/errors.js.map +1 -0
  23. package/dist/v2/index.d.ts +5 -0
  24. package/dist/v2/index.js +45 -0
  25. package/dist/v2/index.js.map +1 -0
  26. package/dist/v2/utils.d.ts +16 -0
  27. package/dist/v2/utils.js +3 -0
  28. package/dist/v2/utils.js.map +1 -0
  29. package/dist/v2/webhooks/index.d.ts +10 -0
  30. package/dist/v2/webhooks/index.js +3 -0
  31. package/dist/v2/webhooks/index.js.map +1 -0
  32. package/package.json +32 -0
  33. package/src/v2/endpoints/index.ts +4 -0
  34. package/src/v2/endpoints/predictions.ts +14 -0
  35. package/src/v2/endpoints/seasons.ts +8 -0
  36. package/src/v2/entities/index.ts +4 -0
  37. package/src/v2/entities/predictions.ts +73 -0
  38. package/src/v2/entities/seasons.ts +11 -0
  39. package/src/v2/errors.ts +41 -0
  40. package/src/v2/index.ts +6 -0
  41. package/src/v2/utils.ts +20 -0
package/README.md ADDED
@@ -0,0 +1,28 @@
1
+ The package is currently in beta.
2
+
3
+ # NDB2 API Types
4
+
5
+ This package provides endpoint, entities, and other response types for the private [NDB2 API](https://github.com/Off-Nominal/ndb2) version 2 and later. You probably don't need this package but feel free to look around if you're super curious and bored.
6
+
7
+ ## Installation
8
+
9
+ `npm install @offnominal/ndb2-api-types`
10
+
11
+ ## Usage
12
+
13
+ API Versions will be appended to the import string. Currently only `v2` is planned.
14
+
15
+ ```ts
16
+ import API from "@offnominal/ndb2-api-types/v2";
17
+ ```
18
+
19
+ ### Subtypes
20
+
21
+ The following types are available namespaced under your import value.
22
+
23
+ - Endpoints - Specific responses from each endpoint
24
+ - Entities - Data only types, which are wrapped in response objects for Endpoints
25
+ - Utils - Response Wrapper types
26
+ - Errors - Error Code enum for different error values you may receive
27
+
28
+ - Note, `Errors` is an enum, and therefore a value. This means you must import your types as a value and not a type.
@@ -0,0 +1,3 @@
1
+ import * as Predictions from "./predictions";
2
+ import * as Seasons from "./seasons";
3
+ export { Predictions, Seasons };
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.Seasons = exports.Predictions = void 0;
37
+ const Predictions = __importStar(require("./predictions"));
38
+ exports.Predictions = Predictions;
39
+ const Seasons = __importStar(require("./seasons"));
40
+ exports.Seasons = Seasons;
41
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/v2/endpoints/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2DAA6C;AAGpC,kCAAW;AAFpB,mDAAqC;AAEf,0BAAO"}
@@ -0,0 +1,10 @@
1
+ import { Entities } from "..";
2
+ import { APIResponse } from "../utils";
3
+ export declare namespace GET_ById {
4
+ type Data = Entities.Predictions.Prediction;
5
+ type Response = APIResponse<Data>;
6
+ }
7
+ export declare namespace DELETE_ById_trigger {
8
+ type Data = null;
9
+ type Response = APIResponse<Data>;
10
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=predictions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"predictions.js","sourceRoot":"","sources":["../../../src/v2/endpoints/predictions.ts"],"names":[],"mappings":""}
@@ -0,0 +1,6 @@
1
+ import { Entities } from "..";
2
+ import { APIResponse } from "../utils";
3
+ export declare namespace GET {
4
+ type Data = Entities.Seasons.Season[];
5
+ type Response = APIResponse<Data>;
6
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=seasons.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"seasons.js","sourceRoot":"","sources":["../../../src/v2/endpoints/seasons.ts"],"names":[],"mappings":""}
@@ -0,0 +1,3 @@
1
+ import * as Predictions from "./predictions";
2
+ import * as Seasons from "./seasons";
3
+ export { Predictions, Seasons };
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.Seasons = exports.Predictions = void 0;
37
+ const Predictions = __importStar(require("./predictions"));
38
+ exports.Predictions = Predictions;
39
+ const Seasons = __importStar(require("./seasons"));
40
+ exports.Seasons = Seasons;
41
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/v2/entities/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2DAA6C;AAGpC,kCAAW;AAFpB,mDAAqC;AAEf,0BAAO"}
@@ -0,0 +1,65 @@
1
+ export type PredictionDriver = "event" | "date";
2
+ export type PredictionLifeCycle = "checking" | "closed" | "failed" | "open" | "retired" | "successful";
3
+ export type Prediction = {
4
+ id: number;
5
+ predictor: {
6
+ id: string;
7
+ discord_id: string;
8
+ };
9
+ text: string;
10
+ driver: PredictionDriver;
11
+ season_id: number | null;
12
+ season_applicable: boolean;
13
+ created_date: Date;
14
+ due_date: Date | null;
15
+ check_date: Date | null;
16
+ last_check_date: Date | null;
17
+ closed_date: Date | null;
18
+ triggered_date: Date | null;
19
+ triggerer: {
20
+ id: string;
21
+ discord_id: string;
22
+ } | null;
23
+ judged_date: Date | null;
24
+ retired_date: Date | null;
25
+ status: PredictionLifeCycle;
26
+ bets: {
27
+ id: number;
28
+ endorsed: boolean;
29
+ date: Date;
30
+ wager: number;
31
+ valid: boolean;
32
+ payout: number | null;
33
+ season_payout: number | null;
34
+ better: {
35
+ id: string;
36
+ discord_id: string;
37
+ };
38
+ }[];
39
+ votes: {
40
+ id: number;
41
+ vote: boolean;
42
+ voted_date: Date;
43
+ voter: {
44
+ id: string;
45
+ discord_id: string;
46
+ };
47
+ }[];
48
+ checks: {
49
+ id: number;
50
+ check_date: Date;
51
+ closed: boolean;
52
+ closed_at: Date | null;
53
+ votes: {
54
+ day: number;
55
+ week: number;
56
+ month: number;
57
+ quarter: number;
58
+ year: number;
59
+ };
60
+ }[];
61
+ payouts: {
62
+ endorse: number;
63
+ undorse: number;
64
+ };
65
+ };
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=predictions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"predictions.js","sourceRoot":"","sources":["../../../src/v2/entities/predictions.ts"],"names":[],"mappings":""}
@@ -0,0 +1,10 @@
1
+ export type Identifier = "current" | "past" | "future";
2
+ export type Season = {
3
+ id: number;
4
+ name: string;
5
+ start: string;
6
+ end: string;
7
+ wager_cap: number;
8
+ closed: boolean;
9
+ identifier: Identifier;
10
+ };
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=seasons.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"seasons.js","sourceRoot":"","sources":["../../../src/v2/entities/seasons.ts"],"names":[],"mappings":""}
@@ -0,0 +1,12 @@
1
+ export declare const Errors: {
2
+ readonly SERVER_ERROR: 90000;
3
+ readonly MALFORMED_BODY_DATA: 90001;
4
+ readonly MALFORMED_QUERY_PARAMS: 90002;
5
+ readonly MALFORMED_URL_PARAMS: 90003;
6
+ readonly PREDICTION_NOT_FOUND: 90200;
7
+ readonly INVALID_PREDICTION_STATUS: 90201;
8
+ readonly INVALID_CHECK_DATE: 90202;
9
+ readonly BETS_NO_CHANGE: 90501;
10
+ readonly BETS_UNCHANGEABLE: 90502;
11
+ };
12
+ export type NDB2APIError = (typeof Errors)[keyof typeof Errors];
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ // Error Legend
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.Errors = void 0;
5
+ // First digit - 9
6
+ // Digits 1 and 2 - Resource
7
+ // Digits 3 and 4 - Error Code
8
+ // Resources
9
+ // 00 - Generic
10
+ // 01 - Users
11
+ // 02 - Predictions
12
+ // 03 - Scores
13
+ // 04 - Seasons
14
+ // 05 - Bets
15
+ // 06 - Votes
16
+ exports.Errors = {
17
+ // Basic Errors
18
+ SERVER_ERROR: 90000,
19
+ MALFORMED_BODY_DATA: 90001,
20
+ MALFORMED_QUERY_PARAMS: 90002,
21
+ MALFORMED_URL_PARAMS: 90003,
22
+ // 01 Users
23
+ // 02 Predictions
24
+ PREDICTION_NOT_FOUND: 90200,
25
+ INVALID_PREDICTION_STATUS: 90201,
26
+ INVALID_CHECK_DATE: 90202,
27
+ // 03 Scores
28
+ // 04 Seasons
29
+ // 05 Bets
30
+ BETS_NO_CHANGE: 90501,
31
+ BETS_UNCHANGEABLE: 90502,
32
+ // 06 Votes
33
+ };
34
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/v2/errors.ts"],"names":[],"mappings":";AAAA,eAAe;;;AAEf,kBAAkB;AAClB,4BAA4B;AAC5B,8BAA8B;AAE9B,YAAY;AACZ,eAAe;AACf,aAAa;AACb,mBAAmB;AACnB,cAAc;AACd,eAAe;AACf,YAAY;AACZ,aAAa;AAEA,QAAA,MAAM,GAAG;IACpB,eAAe;IACf,YAAY,EAAE,KAAK;IACnB,mBAAmB,EAAE,KAAK;IAC1B,sBAAsB,EAAE,KAAK;IAC7B,oBAAoB,EAAE,KAAK;IAE3B,WAAW;IAEX,iBAAiB;IACjB,oBAAoB,EAAE,KAAK;IAC3B,yBAAyB,EAAE,KAAK;IAChC,kBAAkB,EAAE,KAAK;IAEzB,YAAY;IAEZ,aAAa;IAEb,UAAU;IACV,cAAc,EAAE,KAAK;IACrB,iBAAiB,EAAE,KAAK;IAExB,WAAW;CACH,CAAC"}
@@ -0,0 +1,5 @@
1
+ import * as Entities from "./entities";
2
+ import * as Endpoints from "./endpoints";
3
+ import { Errors, NDB2APIError } from "./errors";
4
+ import * as Utils from "./utils";
5
+ export { Entities, Endpoints, Errors, NDB2APIError, Utils };
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.Utils = exports.Errors = exports.Endpoints = exports.Entities = void 0;
37
+ const Entities = __importStar(require("./entities"));
38
+ exports.Entities = Entities;
39
+ const Endpoints = __importStar(require("./endpoints"));
40
+ exports.Endpoints = Endpoints;
41
+ const errors_1 = require("./errors");
42
+ Object.defineProperty(exports, "Errors", { enumerable: true, get: function () { return errors_1.Errors; } });
43
+ const Utils = __importStar(require("./utils"));
44
+ exports.Utils = Utils;
45
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/v2/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qDAAuC;AAK9B,4BAAQ;AAJjB,uDAAyC;AAItB,8BAAS;AAH5B,qCAAgD;AAGlB,uFAHrB,eAAM,OAGqB;AAFpC,+CAAiC;AAEmB,sBAAK"}
@@ -0,0 +1,16 @@
1
+ import { NDB2APIError } from "./errors";
2
+ export type SuccessResponse<T> = {
3
+ success: true;
4
+ message: string | null;
5
+ data: T;
6
+ };
7
+ export type ErrorInfo = {
8
+ code: NDB2APIError;
9
+ message: string;
10
+ };
11
+ export type ErrorResponse = {
12
+ success: false;
13
+ errors: ErrorInfo[];
14
+ data: null;
15
+ };
16
+ export type APIResponse<T> = SuccessResponse<T> | ErrorResponse;
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/v2/utils.ts"],"names":[],"mappings":""}
@@ -0,0 +1,10 @@
1
+ import { Entities } from "..";
2
+ type BaseWebhookPayload = {
3
+ event_id: string;
4
+ emitted_at: string;
5
+ };
6
+ export type UntriggeredPrediction = BaseWebhookPayload & {
7
+ event: "untriggered_prediction";
8
+ data: Entities.Predictions.Prediction;
9
+ };
10
+ export {};
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/v2/webhooks/index.ts"],"names":[],"mappings":""}
package/package.json ADDED
@@ -0,0 +1,32 @@
1
+ {
2
+ "name": "@offnominal/ndb2-api-types",
3
+ "version": "0.2.2",
4
+ "author": "Jake Robins",
5
+ "types": "./src/v2/index.ts",
6
+ "main": "./dist/v2/index.js",
7
+ "exports": {
8
+ "./v2": {
9
+ "types": "./src/v2/index.ts",
10
+ "default": "./dist/v2/index.js",
11
+ "source": "./src/v2/index.ts"
12
+ }
13
+ },
14
+ "files": [
15
+ "dist",
16
+ "src"
17
+ ],
18
+ "scripts": {
19
+ "build": "tsc",
20
+ "clear": "rm -rf ./dist",
21
+ "compile": "pnpm run clear && pnpm run build && node ./dist/index.js",
22
+ "dev": "NODE_ENV=dev nodemon --exec \"pnpm run build\"",
23
+ "prepublishOnly": "npm run build"
24
+ },
25
+ "devDependencies": {
26
+ "nodemon": "^3.1.10",
27
+ "typescript": "^5.8.3"
28
+ },
29
+ "license": "ISC",
30
+ "description": "Typescript Types for NDB2 API",
31
+ "homepage": "https://github.com/mendahu/ndb2#readme"
32
+ }
@@ -0,0 +1,4 @@
1
+ import * as Predictions from "./predictions";
2
+ import * as Seasons from "./seasons";
3
+
4
+ export { Predictions, Seasons };
@@ -0,0 +1,14 @@
1
+ import { Entities } from "..";
2
+ import { APIResponse } from "../utils";
3
+
4
+ // GET /predictions/{prediction_id}/
5
+ export namespace GET_ById {
6
+ export type Data = Entities.Predictions.Prediction;
7
+ export type Response = APIResponse<Data>;
8
+ }
9
+
10
+ // DELETE /predictions/{prediction_id}/trigger
11
+ export namespace DELETE_ById_trigger {
12
+ export type Data = null;
13
+ export type Response = APIResponse<Data>;
14
+ }
@@ -0,0 +1,8 @@
1
+ import { Entities } from "..";
2
+ import { APIResponse } from "../utils";
3
+
4
+ // GET /seasons/
5
+ export namespace GET {
6
+ export type Data = Entities.Seasons.Season[];
7
+ export type Response = APIResponse<Data>;
8
+ }
@@ -0,0 +1,4 @@
1
+ import * as Predictions from "./predictions";
2
+ import * as Seasons from "./seasons";
3
+
4
+ export { Predictions, Seasons };
@@ -0,0 +1,73 @@
1
+ export type PredictionDriver = "event" | "date";
2
+
3
+ export type PredictionLifeCycle =
4
+ | "checking"
5
+ | "closed"
6
+ | "failed"
7
+ | "open"
8
+ | "retired"
9
+ | "successful";
10
+
11
+ export type Prediction = {
12
+ id: number;
13
+ predictor: {
14
+ id: string;
15
+ discord_id: string;
16
+ };
17
+ text: string;
18
+ driver: PredictionDriver;
19
+ season_id: number | null;
20
+ season_applicable: boolean;
21
+ created_date: Date;
22
+ due_date: Date | null;
23
+ check_date: Date | null;
24
+ last_check_date: Date | null;
25
+ closed_date: Date | null;
26
+ triggered_date: Date | null;
27
+ triggerer: {
28
+ id: string;
29
+ discord_id: string;
30
+ } | null;
31
+ judged_date: Date | null;
32
+ retired_date: Date | null;
33
+ status: PredictionLifeCycle;
34
+ bets: {
35
+ id: number;
36
+ endorsed: boolean;
37
+ date: Date;
38
+ wager: number;
39
+ valid: boolean;
40
+ payout: number | null;
41
+ season_payout: number | null;
42
+ better: {
43
+ id: string;
44
+ discord_id: string;
45
+ };
46
+ }[];
47
+ votes: {
48
+ id: number;
49
+ vote: boolean;
50
+ voted_date: Date;
51
+ voter: {
52
+ id: string;
53
+ discord_id: string;
54
+ };
55
+ }[];
56
+ checks: {
57
+ id: number;
58
+ check_date: Date;
59
+ closed: boolean;
60
+ closed_at: Date | null;
61
+ votes: {
62
+ day: number;
63
+ week: number;
64
+ month: number;
65
+ quarter: number;
66
+ year: number;
67
+ };
68
+ }[];
69
+ payouts: {
70
+ endorse: number;
71
+ undorse: number;
72
+ };
73
+ };
@@ -0,0 +1,11 @@
1
+ export type Identifier = "current" | "past" | "future";
2
+
3
+ export type Season = {
4
+ id: number;
5
+ name: string;
6
+ start: string;
7
+ end: string;
8
+ wager_cap: number;
9
+ closed: boolean;
10
+ identifier: Identifier;
11
+ };
@@ -0,0 +1,41 @@
1
+ // Error Legend
2
+
3
+ // First digit - 9
4
+ // Digits 1 and 2 - Resource
5
+ // Digits 3 and 4 - Error Code
6
+
7
+ // Resources
8
+ // 00 - Generic
9
+ // 01 - Users
10
+ // 02 - Predictions
11
+ // 03 - Scores
12
+ // 04 - Seasons
13
+ // 05 - Bets
14
+ // 06 - Votes
15
+
16
+ export const Errors = {
17
+ // Basic Errors
18
+ SERVER_ERROR: 90000,
19
+ MALFORMED_BODY_DATA: 90001,
20
+ MALFORMED_QUERY_PARAMS: 90002,
21
+ MALFORMED_URL_PARAMS: 90003,
22
+
23
+ // 01 Users
24
+
25
+ // 02 Predictions
26
+ PREDICTION_NOT_FOUND: 90200,
27
+ INVALID_PREDICTION_STATUS: 90201,
28
+ INVALID_CHECK_DATE: 90202,
29
+
30
+ // 03 Scores
31
+
32
+ // 04 Seasons
33
+
34
+ // 05 Bets
35
+ BETS_NO_CHANGE: 90501,
36
+ BETS_UNCHANGEABLE: 90502,
37
+
38
+ // 06 Votes
39
+ } as const;
40
+
41
+ export type NDB2APIError = (typeof Errors)[keyof typeof Errors];
@@ -0,0 +1,6 @@
1
+ import * as Entities from "./entities";
2
+ import * as Endpoints from "./endpoints";
3
+ import { Errors, NDB2APIError } from "./errors";
4
+ import * as Utils from "./utils";
5
+
6
+ export { Entities, Endpoints, Errors, NDB2APIError, Utils };
@@ -0,0 +1,20 @@
1
+ import { NDB2APIError } from "./errors";
2
+
3
+ export type SuccessResponse<T> = {
4
+ success: true;
5
+ message: string | null;
6
+ data: T;
7
+ };
8
+
9
+ export type ErrorInfo = {
10
+ code: NDB2APIError;
11
+ message: string;
12
+ };
13
+
14
+ export type ErrorResponse = {
15
+ success: false;
16
+ errors: ErrorInfo[];
17
+ data: null;
18
+ };
19
+
20
+ export type APIResponse<T> = SuccessResponse<T> | ErrorResponse;