innovint-client 1.0.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.
- package/dist/client/base.d.ts +18 -0
- package/dist/client/base.d.ts.map +1 -0
- package/dist/client/internal.d.ts +2 -0
- package/dist/client/internal.d.ts.map +1 -0
- package/dist/client/v1.d.ts +21 -0
- package/dist/client/v1.d.ts.map +1 -0
- package/dist/data/access.d.ts +12 -0
- package/dist/data/access.d.ts.map +1 -0
- package/dist/data/action/action.d.ts +13 -0
- package/dist/data/action/action.d.ts.map +1 -0
- package/dist/data/action/addition.d.ts +26 -0
- package/dist/data/action/addition.d.ts.map +1 -0
- package/dist/data/action/analysis.d.ts +33 -0
- package/dist/data/action/analysis.d.ts.map +1 -0
- package/dist/data/lot.d.ts +31 -0
- package/dist/data/lot.d.ts.map +1 -0
- package/dist/data/object.d.ts +5 -0
- package/dist/data/object.d.ts.map +1 -0
- package/dist/data/unit.d.ts +7 -0
- package/dist/data/unit.d.ts.map +1 -0
- package/dist/data/vessel.d.ts +18 -0
- package/dist/data/vessel.d.ts.map +1 -0
- package/dist/exception.d.ts +9 -0
- package/dist/exception.d.ts.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/innovint-client.js +157 -0
- package/dist/innovint-client.js.map +1 -0
- package/dist/innovint-client.umd.cjs +2 -0
- package/dist/innovint-client.umd.cjs.map +1 -0
- package/dist/request.d.ts +37 -0
- package/dist/request.d.ts.map +1 -0
- package/dist/response.d.ts +21 -0
- package/dist/response.d.ts.map +1 -0
- package/package.json +46 -0
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { InnoVintRequestParams } from '../request.ts';
|
|
2
|
+
import { InnoVintListResponse, InnoVintErrorResponse, InnoVintData } from '../response.ts';
|
|
3
|
+
export default abstract class InnoVintClientBase {
|
|
4
|
+
protected readonly baseUrl: string;
|
|
5
|
+
protected readonly accessToken: string;
|
|
6
|
+
protected readonly wineryId: string;
|
|
7
|
+
constructor({ accessToken, wineryId, }: {
|
|
8
|
+
accessToken: string;
|
|
9
|
+
wineryId: string;
|
|
10
|
+
});
|
|
11
|
+
protected authenticatedGet<T>(url: string): Promise<InnoVintListResponse<T> | InnoVintData<T> | InnoVintErrorResponse>;
|
|
12
|
+
protected pathToUrl(path: string, params?: InnoVintRequestParams): string;
|
|
13
|
+
protected paramsToQuery(params: object): string;
|
|
14
|
+
protected paginatedGet<T, R extends InnoVintRequestParams>(path: string, params?: R): Promise<T[]>;
|
|
15
|
+
protected getResultData<T>(response: InnoVintListResponse<T>): T[];
|
|
16
|
+
protected singleGet<T>(path: string, id: string): Promise<T>;
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=base.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../src/client/base.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AACtD,OAAO,EACL,oBAAoB,EACpB,qBAAqB,EACrB,YAAY,EACb,MAAM,gBAAgB,CAAC;AAIxB,MAAM,CAAC,OAAO,CAAC,QAAQ,OAAO,kBAAkB;IAC9C,SAAS,CAAC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAM;IACxC,SAAS,CAAC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IACvC,SAAS,CAAC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;gBAGxB,EACV,WAAW,EACX,QAAQ,GACT,EAAE;QACD,WAAW,EAAE,MAAM,CAAC;QACpB,QAAQ,EAAE,MAAM,CAAC;KAClB;cASe,gBAAgB,CAAC,CAAC,EAChC,GAAG,EAAE,MAAM,GACV,OAAO,CACR,oBAAoB,CAAC,CAAC,CAAC,GAAG,YAAY,CAAC,CAAC,CAAC,GAAG,qBAAqB,CAClE;IAqBD,SAAS,CAAC,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,GAAE,qBAA0B;IAKpE,SAAS,CAAC,aAAa,CAAC,MAAM,EAAE,MAAM;cAOtB,YAAY,CAAC,CAAC,EAAE,CAAC,SAAS,qBAAqB,EAC7D,IAAI,EAAE,MAAM,EACZ,MAAM,GAAE,CAAW;IA4BrB,SAAS,CAAC,aAAa,CAAC,CAAC,EAAE,QAAQ,EAAE,oBAAoB,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE;cAKlD,SAAS,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM;CAMtD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../../src/client/internal.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { default as InnoVintClientBase } from './base.ts';
|
|
2
|
+
import { InnoVintVesselsRequestParams, InnoVintLotsRequestParams, InnoVintActionsRequestParams } from '../request.ts';
|
|
3
|
+
import { default as InnoVintLot } from '../data/lot.ts';
|
|
4
|
+
import { default as InnoVintVessel } from '../data/vessel.ts';
|
|
5
|
+
import { InnoVintAnalysis } from '../data/action/analysis.ts';
|
|
6
|
+
import { InnoVintAdditionAction } from '../data/action/addition.ts';
|
|
7
|
+
export default class InnoVintClientV1 extends InnoVintClientBase {
|
|
8
|
+
protected readonly baseUrl = "https://sutter.innovint.us/api/v1";
|
|
9
|
+
getVessels(params?: InnoVintVesselsRequestParams): Promise<InnoVintVessel[]>;
|
|
10
|
+
getVessel(id: string): Promise<InnoVintVessel>;
|
|
11
|
+
getVesselByCode(code: string): Promise<InnoVintVessel>;
|
|
12
|
+
getVesselsByLotCode(lotCode: string): Promise<InnoVintVessel[]>;
|
|
13
|
+
getVesselsByOwner(ownerName: string, params?: InnoVintVesselsRequestParams): Promise<InnoVintVessel[]>;
|
|
14
|
+
getLots(params?: InnoVintLotsRequestParams): Promise<InnoVintLot[]>;
|
|
15
|
+
getLotsByOwner(ownerName: string, params?: InnoVintLotsRequestParams): Promise<InnoVintLot[]>;
|
|
16
|
+
getLot(id: string): Promise<InnoVintLot>;
|
|
17
|
+
getLotByCode(code: string): Promise<InnoVintLot>;
|
|
18
|
+
getAnalyses(params?: InnoVintActionsRequestParams): Promise<InnoVintAnalysis[]>;
|
|
19
|
+
getAdditionActions(params?: InnoVintActionsRequestParams): Promise<InnoVintAdditionAction[]>;
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=v1.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"v1.d.ts","sourceRoot":"","sources":["../../src/client/v1.ts"],"names":[],"mappings":"AAAA,OAAO,kBAAkB,MAAM,WAAW,CAAC;AAC3C,OAAO,EACL,4BAA4B,EAC5B,yBAAyB,EACzB,4BAA4B,EAC7B,MAAM,eAAe,CAAC;AACvB,OAAO,WAAW,MAAM,gBAAgB,CAAC;AACzC,OAAO,cAAc,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAEL,gBAAgB,EACjB,MAAM,4BAA4B,CAAC;AAEpC,OAAO,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AAGpE,MAAM,CAAC,OAAO,OAAO,gBAAiB,SAAQ,kBAAkB;IAC9D,SAAS,CAAC,QAAQ,CAAC,OAAO,uCAAuC;IAI3D,UAAU,CACd,MAAM,GAAE,4BAAiC,GACxC,OAAO,CAAC,cAAc,EAAE,CAAC;IAStB,SAAS,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC;IAK9C,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC;IAatD,mBAAmB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,EAAE,CAAC;IAS/D,iBAAiB,CACrB,SAAS,EAAE,MAAM,EACjB,MAAM,GAAE,4BAAiC,GACxC,OAAO,CAAC,cAAc,EAAE,CAAC;IAMtB,OAAO,CACX,MAAM,GAAE,yBAA8B,GACrC,OAAO,CAAC,WAAW,EAAE,CAAC;IASnB,cAAc,CAClB,SAAS,EAAE,MAAM,EACjB,MAAM,GAAE,yBAA8B,GACrC,OAAO,CAAC,WAAW,EAAE,CAAC;IAMnB,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC;IAKxC,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC;IAahD,WAAW,CACf,MAAM,GAAE,4BAAiC,GACxC,OAAO,CAAC,gBAAgB,EAAE,CAAC;IAiBxB,kBAAkB,CACtB,MAAM,GAAE,4BAAiC,GACxC,OAAO,CAAC,sBAAsB,EAAE,CAAC;CAarC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export default interface InnoVintAccessData {
|
|
2
|
+
globalAccess: boolean;
|
|
3
|
+
ownerTags: InnoVintOwnerTag[];
|
|
4
|
+
}
|
|
5
|
+
interface InnoVintOwnerTag {
|
|
6
|
+
id: number;
|
|
7
|
+
publicId: string;
|
|
8
|
+
internalId: number;
|
|
9
|
+
name: string;
|
|
10
|
+
}
|
|
11
|
+
export {};
|
|
12
|
+
//# sourceMappingURL=access.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"access.d.ts","sourceRoot":"","sources":["../../src/data/access.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,OAAO,WAAW,kBAAkB;IACzC,YAAY,EAAE,OAAO,CAAC;IACtB,SAAS,EAAE,gBAAgB,EAAE,CAAC;CAC/B;AAED,UAAU,gBAAgB;IACxB,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;CACd"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { default as InnoVintObject } from '../object.ts';
|
|
2
|
+
type InnoVintActionType = "ADDITION" | "ANALYSIS" | "BARREL_DOWN" | "BATCH_ADJUSTMENT" | "BLEED" | "DRAIN" | "BLEND" | "BOTTLE" | "BOTTLING_EN_TIRAGE" | "DISTILLATION" | "COST_ITEM" | "CREATE_LOT" | "CREATE_VESSELS" | "DRAIN_AND_PRESS" | "DISGORGE_DOSAGE_PACKAGE" | "FILTER" | "FRUIT_WEIGHT_CHANGE" | "LOT_TAX_CLASS_CHANGE" | "PROCESS_FRUIT_TO_VOLUME" | "PROCESS_FRUIT_TO_WEIGHT" | "PULL_SAMPLE" | "RACK" | "RACK_AND_RETURN" | "RECEIVE_DRY_GOOD" | "RECEIVE_FRUIT" | "TOPPING" | "TOP_OFF" | "TRANSFER" | "TRANSFER_INTER_FACILITY" | "TRANSFER_VOLUME_TO_WEIGHT" | "UPDATE_LOT" | "CUSTOM" | "VOLUME_CHANGE" | "WATER_ADD" | "WEIGHT_CHANGE" | "WEIGHT_TRANSFER" | "MAKEUP_CHANGE";
|
|
3
|
+
export default interface InnoVintAction extends InnoVintObject {
|
|
4
|
+
actionType: InnoVintActionType;
|
|
5
|
+
applied: boolean;
|
|
6
|
+
deleted: boolean;
|
|
7
|
+
effectiveAt: string;
|
|
8
|
+
createdAt: string;
|
|
9
|
+
updatedAt: string;
|
|
10
|
+
referenceNumber: string;
|
|
11
|
+
}
|
|
12
|
+
export {};
|
|
13
|
+
//# sourceMappingURL=action.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"action.d.ts","sourceRoot":"","sources":["../../../src/data/action/action.ts"],"names":[],"mappings":"AAAA,OAAO,cAAc,MAAM,cAAc,CAAC;AAE1C,KAAK,kBAAkB,GACnB,UAAU,GACV,UAAU,GACV,aAAa,GACb,kBAAkB,GAClB,OAAO,GACP,OAAO,GACP,OAAO,GACP,QAAQ,GACR,oBAAoB,GACpB,cAAc,GACd,WAAW,GACX,YAAY,GACZ,gBAAgB,GAChB,iBAAiB,GACjB,yBAAyB,GACzB,QAAQ,GACR,qBAAqB,GACrB,sBAAsB,GACtB,yBAAyB,GACzB,yBAAyB,GACzB,aAAa,GACb,MAAM,GACN,iBAAiB,GACjB,kBAAkB,GAClB,eAAe,GACf,SAAS,GACT,SAAS,GACT,UAAU,GACV,yBAAyB,GACzB,2BAA2B,GAC3B,YAAY,GACZ,QAAQ,GACR,eAAe,GACf,WAAW,GACX,eAAe,GACf,iBAAiB,GACjB,eAAe,CAAC;AAEpB,MAAM,CAAC,OAAO,WAAW,cAAe,SAAQ,cAAc;IAC5D,UAAU,EAAE,kBAAkB,CAAC;IAC/B,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,EAAE,OAAO,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,eAAe,EAAE,MAAM,CAAC;CACzB"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { default as InnoVintAction } from './action.ts';
|
|
2
|
+
export interface InnoVintAdditionAction extends InnoVintAction {
|
|
3
|
+
actionType: "ADDITION";
|
|
4
|
+
additions: InnoVintAddition[];
|
|
5
|
+
additives: InnoVintAdditive[];
|
|
6
|
+
}
|
|
7
|
+
interface InnoVintAdditive {
|
|
8
|
+
additiveId: string;
|
|
9
|
+
additionRateUnit: string;
|
|
10
|
+
additionRateValue: number;
|
|
11
|
+
instructions?: string;
|
|
12
|
+
batches: InnoVintAdditionBatch[];
|
|
13
|
+
}
|
|
14
|
+
interface InnoVintAdditionBatch {
|
|
15
|
+
batchId: string;
|
|
16
|
+
amount: number;
|
|
17
|
+
depleted: boolean;
|
|
18
|
+
}
|
|
19
|
+
interface InnoVintAddition {
|
|
20
|
+
lotId: string;
|
|
21
|
+
vesselId: string;
|
|
22
|
+
additiveId: string;
|
|
23
|
+
amount: number;
|
|
24
|
+
}
|
|
25
|
+
export {};
|
|
26
|
+
//# sourceMappingURL=addition.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"addition.d.ts","sourceRoot":"","sources":["../../../src/data/action/addition.ts"],"names":[],"mappings":"AAAA,OAAO,cAAc,MAAM,aAAa,CAAC;AAEzC,MAAM,WAAW,sBAAuB,SAAQ,cAAc;IAC5D,UAAU,EAAE,UAAU,CAAC;IACvB,SAAS,EAAE,gBAAgB,EAAE,CAAC;IAC9B,SAAS,EAAE,gBAAgB,EAAE,CAAC;CAC/B;AAED,UAAU,gBAAgB;IACxB,UAAU,EAAE,MAAM,CAAC;IACnB,gBAAgB,EAAE,MAAM,CAAC;IACzB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,OAAO,EAAE,qBAAqB,EAAE,CAAC;CAClC;AAED,UAAU,qBAAqB;IAC7B,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,OAAO,CAAC;CACnB;AAED,UAAU,gBAAgB;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;CAChB"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { default as InnoVintAction } from './action.ts';
|
|
2
|
+
type InnoVintAnalysisSource = "IN-HOUSE" | "INNOVINT" | "ADMEO" | "ANTON_PAAR" | "BAKER" | "BARRELWISE" | "BEVTRAC" | "CLOUDSPEC" | "CV_WINE_LAB" | "CORE_ENOLOGY" | "CORNELL" | "ENOLOGIA_INTEGRAL" | "ERICA_ORR" | "ETS_MANUAL" | "FOSS" | "GENESYS" | "GROWER" | "ICV_OENOLOGICAL_LABORATORY" | "JH_WINE" | "LODI" | "MY_ENOLOGIST" | "ONAFIS" | "SENTIA" | "TANKNET" | "THERMOFISHER_SCIENTIFIC" | "VINQUIRY_MANUAL" | "VINSCI" | "VINWIZARD" | "WINELAB" | "WINEXRAY";
|
|
3
|
+
export interface InnoVintAnalysisAction extends InnoVintAction {
|
|
4
|
+
actionType: "ANALYSIS";
|
|
5
|
+
panelName: string;
|
|
6
|
+
source: InnoVintAnalysisSource;
|
|
7
|
+
analyses: InnoVintAnalysis[];
|
|
8
|
+
}
|
|
9
|
+
interface InnoVintAnalysisType {
|
|
10
|
+
name: string;
|
|
11
|
+
abbreviation?: string;
|
|
12
|
+
slug?: string;
|
|
13
|
+
}
|
|
14
|
+
interface InnoVintAnalysisComponent {
|
|
15
|
+
blockId: string;
|
|
16
|
+
vintage: number;
|
|
17
|
+
}
|
|
18
|
+
interface InnoVintAnalysisUnit {
|
|
19
|
+
name: string;
|
|
20
|
+
unit: string;
|
|
21
|
+
}
|
|
22
|
+
export interface InnoVintAnalysis {
|
|
23
|
+
id: string;
|
|
24
|
+
analysisType: InnoVintAnalysisType;
|
|
25
|
+
component?: InnoVintAnalysisComponent;
|
|
26
|
+
recordedAt?: string;
|
|
27
|
+
skipped: boolean;
|
|
28
|
+
unit: InnoVintAnalysisUnit;
|
|
29
|
+
value?: number;
|
|
30
|
+
vesselId?: string;
|
|
31
|
+
}
|
|
32
|
+
export {};
|
|
33
|
+
//# sourceMappingURL=analysis.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"analysis.d.ts","sourceRoot":"","sources":["../../../src/data/action/analysis.ts"],"names":[],"mappings":"AAAA,OAAO,cAAc,MAAM,aAAa,CAAC;AAEzC,KAAK,sBAAsB,GACvB,UAAU,GACV,UAAU,GACV,OAAO,GACP,YAAY,GACZ,OAAO,GACP,YAAY,GACZ,SAAS,GACT,WAAW,GACX,aAAa,GACb,cAAc,GACd,SAAS,GACT,mBAAmB,GACnB,WAAW,GACX,YAAY,GACZ,MAAM,GACN,SAAS,GACT,QAAQ,GACR,4BAA4B,GAC5B,SAAS,GACT,MAAM,GACN,cAAc,GACd,QAAQ,GACR,QAAQ,GACR,SAAS,GACT,yBAAyB,GACzB,iBAAiB,GACjB,QAAQ,GACR,WAAW,GACX,SAAS,GACT,UAAU,CAAC;AAEf,MAAM,WAAW,sBAAuB,SAAQ,cAAc;IAC5D,UAAU,EAAE,UAAU,CAAC;IACvB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,sBAAsB,CAAC;IAC/B,QAAQ,EAAE,gBAAgB,EAAE,CAAC;CAC9B;AAED,UAAU,oBAAoB;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,UAAU,yBAAyB;IACjC,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,UAAU,oBAAoB;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,gBAAgB;IAC/B,EAAE,EAAE,MAAM,CAAC;IACX,YAAY,EAAE,oBAAoB,CAAC;IACnC,SAAS,CAAC,EAAE,yBAAyB,CAAC;IACtC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,EAAE,oBAAoB,CAAC;IAC3B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { default as InnoVintObject } from './object.ts';
|
|
2
|
+
import { default as InnoVintAccessData } from './access.ts';
|
|
3
|
+
import { InnoVintWeightOrVolume } from './unit.ts';
|
|
4
|
+
type InnoVintLotColor = "red" | "white" | "rose" | "orange";
|
|
5
|
+
type InnoVintLotStyle = "STILL" | "SPARKLING";
|
|
6
|
+
type InnoVintLotType = "BULK" | "CASE_GOODS" | "CONCENTRATE" | "CULTURE" | "FRUIT" | "JUICE_WINE";
|
|
7
|
+
type InnoVintLotTaxClass = "TC_UNDECLARED" | "TC_UNCRUSHED_FRUIT" | "TC_FERMENTING_JUICE" | "TC_SWEETENING_JUICE" | "TC_LESS_THAN_14" | "TC_14_TO_21" | "TC_LESS_THAN_16" | "TC_16_TO_21" | "TC_21_TO_24" | "TC_ARTIFICIALLY_CARBONATED" | "TC_SPARKLING" | "TC_SPARKLING_BULK_PROCESSED" | "TC_HARD_CIDER" | "TC_BRANDY_OR_DISTILLED_SPIRIT" | "TC_VERMOUTH" | "TC_NON_LESS_THAN_14" | "TC_NON_14_TO_21" | "TC_DISTILLED_MATERIAL" | "TC_VINEGAR_STOCK" | "TC_CONCENTRATE" | "TC_DISTILLED_AT_160_OR_UNDER" | "TC_DISTILLED_AT_OVER_160" | "TC_BRANDY_DISTILLED_AT_170_OR_UNDER" | "TC_BRANDY_DISTILLED_AT_OVER_170" | "TC_VODKA" | "TC_GIN" | "TC_RUM" | "TC_MASH";
|
|
8
|
+
type InnoVintLotStage = "COLD_SOAK" | "ML" | "BLENDED" | "FERMENTING" | "PRE_BOTTLING_STABILIZATION" | "AGING" | "PROCESSED" | "BOTTLED" | "PLANNED" | "RECEIVED" | "SETTLING" | "EXTENDED_MACERATION" | "EN_TIRAGE" | "RIDDLING" | "SHINER" | "UNFINISHED" | "PRE_RELEASE" | "AVAILABLE_FOR_ORDER" | "ALLOCATED" | "SHIPPED_OUT" | "TAXPAID";
|
|
9
|
+
export default interface InnoVintLot extends InnoVintObject {
|
|
10
|
+
tags: string[];
|
|
11
|
+
access: InnoVintAccessData;
|
|
12
|
+
bondId: string;
|
|
13
|
+
bottlesOnHand: {
|
|
14
|
+
cases: number;
|
|
15
|
+
bottles: number;
|
|
16
|
+
};
|
|
17
|
+
code: string;
|
|
18
|
+
color: InnoVintLotColor;
|
|
19
|
+
fruitWeight: InnoVintWeightOrVolume;
|
|
20
|
+
lotStyle: InnoVintLotStyle;
|
|
21
|
+
lotType: InnoVintLotType;
|
|
22
|
+
taxClass: InnoVintLotTaxClass;
|
|
23
|
+
volume: InnoVintWeightOrVolume;
|
|
24
|
+
weight: InnoVintWeightOrVolume;
|
|
25
|
+
archived: boolean;
|
|
26
|
+
expectedYield: number;
|
|
27
|
+
name: string;
|
|
28
|
+
stage: InnoVintLotStage;
|
|
29
|
+
}
|
|
30
|
+
export {};
|
|
31
|
+
//# sourceMappingURL=lot.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lot.d.ts","sourceRoot":"","sources":["../../src/data/lot.ts"],"names":[],"mappings":"AAAA,OAAO,cAAc,MAAM,aAAa,CAAC;AACzC,OAAO,kBAAkB,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,sBAAsB,EAAE,MAAM,WAAW,CAAC;AAEnD,KAAK,gBAAgB,GAAG,KAAK,GAAG,OAAO,GAAG,MAAM,GAAG,QAAQ,CAAC;AAC5D,KAAK,gBAAgB,GAAG,OAAO,GAAG,WAAW,CAAC;AAC9C,KAAK,eAAe,GAChB,MAAM,GACN,YAAY,GACZ,aAAa,GACb,SAAS,GACT,OAAO,GACP,YAAY,CAAC;AACjB,KAAK,mBAAmB,GACpB,eAAe,GACf,oBAAoB,GACpB,qBAAqB,GACrB,qBAAqB,GACrB,iBAAiB,GACjB,aAAa,GACb,iBAAiB,GACjB,aAAa,GACb,aAAa,GACb,4BAA4B,GAC5B,cAAc,GACd,6BAA6B,GAC7B,eAAe,GACf,+BAA+B,GAC/B,aAAa,GACb,qBAAqB,GACrB,iBAAiB,GACjB,uBAAuB,GACvB,kBAAkB,GAClB,gBAAgB,GAChB,8BAA8B,GAC9B,0BAA0B,GAC1B,qCAAqC,GACrC,iCAAiC,GACjC,UAAU,GACV,QAAQ,GACR,QAAQ,GACR,SAAS,CAAC;AACd,KAAK,gBAAgB,GACjB,WAAW,GACX,IAAI,GACJ,SAAS,GACT,YAAY,GACZ,4BAA4B,GAC5B,OAAO,GACP,WAAW,GACX,SAAS,GACT,SAAS,GACT,UAAU,GACV,UAAU,GACV,qBAAqB,GACrB,WAAW,GACX,UAAU,GACV,QAAQ,GACR,YAAY,GACZ,aAAa,GACb,qBAAqB,GACrB,WAAW,GACX,aAAa,GACb,SAAS,CAAC;AAEd,MAAM,CAAC,OAAO,WAAW,WAAY,SAAQ,cAAc;IACzD,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,MAAM,EAAE,kBAAkB,CAAC;IAC3B,MAAM,EAAE,MAAM,CAAC;IACf,aAAa,EAAE;QACb,KAAK,EAAE,MAAM,CAAC;QACd,OAAO,EAAE,MAAM,CAAC;KACjB,CAAC;IACF,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,gBAAgB,CAAC;IACxB,WAAW,EAAE,sBAAsB,CAAC;IACpC,QAAQ,EAAE,gBAAgB,CAAC;IAC3B,OAAO,EAAE,eAAe,CAAC;IACzB,QAAQ,EAAE,mBAAmB,CAAC;IAC9B,MAAM,EAAE,sBAAsB,CAAC;IAC/B,MAAM,EAAE,sBAAsB,CAAC;IAC/B,QAAQ,EAAE,OAAO,CAAC;IAClB,aAAa,EAAE,MAAM,CAAC;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,gBAAgB,CAAC;CACzB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"object.d.ts","sourceRoot":"","sources":["../../src/data/object.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,OAAO,WAAW,cAAc;IACrC,EAAE,EAAE,MAAM,CAAC;IACX,UAAU,EAAE,MAAM,CAAC;CACpB"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
type InnoVintWeightOrVolumeUnit = "gal" | "gallons" | "gallon" | "hl" | "hL" | "liters" | "litres" | "L" | "pg" | "PG" | "kg" | "kilograms" | "lbs" | "tonne" | "tonnes" | "tons" | "ton";
|
|
2
|
+
export interface InnoVintWeightOrVolume {
|
|
3
|
+
value: number;
|
|
4
|
+
unit: InnoVintWeightOrVolumeUnit;
|
|
5
|
+
}
|
|
6
|
+
export {};
|
|
7
|
+
//# sourceMappingURL=unit.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"unit.d.ts","sourceRoot":"","sources":["../../src/data/unit.ts"],"names":[],"mappings":"AAAA,KAAK,0BAA0B,GAC3B,KAAK,GACL,SAAS,GACT,QAAQ,GACR,IAAI,GACJ,IAAI,GACJ,QAAQ,GACR,QAAQ,GACR,GAAG,GACH,IAAI,GACJ,IAAI,GACJ,IAAI,GACJ,WAAW,GACX,KAAK,GACL,OAAO,GACP,QAAQ,GACR,MAAM,GACN,KAAK,CAAC;AAEV,MAAM,WAAW,sBAAsB;IACrC,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,0BAA0B,CAAC;CAClC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { default as InnoVintObject } from './object.ts';
|
|
2
|
+
import { default as InnoVintAccessData } from './access.ts';
|
|
3
|
+
import { InnoVintWeightOrVolume } from './unit.ts';
|
|
4
|
+
type InnoVintVesselColor = "RED" | "WHITE" | "ROSÉ" | "N/A" | "" | null;
|
|
5
|
+
type InnoVintVesselType = "AMPHORA" | "BARREL" | "BIN" | "CARBOY" | "EGG" | "KEG" | "STEEL_DRUM" | "SUTTER" | "TANK" | "TIRAGE";
|
|
6
|
+
export default interface InnoVintVessel extends InnoVintObject {
|
|
7
|
+
access: InnoVintAccessData;
|
|
8
|
+
capacity: InnoVintWeightOrVolume;
|
|
9
|
+
volume: InnoVintWeightOrVolume;
|
|
10
|
+
weight: InnoVintWeightOrVolume;
|
|
11
|
+
code: string;
|
|
12
|
+
color?: InnoVintVesselColor;
|
|
13
|
+
vesselType: InnoVintVesselType;
|
|
14
|
+
lotId: string;
|
|
15
|
+
archived?: boolean;
|
|
16
|
+
}
|
|
17
|
+
export {};
|
|
18
|
+
//# sourceMappingURL=vessel.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vessel.d.ts","sourceRoot":"","sources":["../../src/data/vessel.ts"],"names":[],"mappings":"AAAA,OAAO,cAAc,MAAM,aAAa,CAAC;AACzC,OAAO,kBAAkB,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,sBAAsB,EAAE,MAAM,WAAW,CAAC;AAEnD,KAAK,mBAAmB,GAAG,KAAK,GAAG,OAAO,GAAG,MAAM,GAAG,KAAK,GAAG,EAAE,GAAG,IAAI,CAAC;AACxE,KAAK,kBAAkB,GAAG,SAAS,GAAG,QAAQ,GAAG,KAAK,GAAG,QAAQ,GAAG,KAAK,GAAG,KAAK,GAAG,YAAY,GAAG,QAAQ,GAAG,MAAM,GAAG,QAAQ,CAAC;AAEhI,MAAM,CAAC,OAAO,WAAW,cAAe,SAAQ,cAAc;IAC5D,MAAM,EAAE,kBAAkB,CAAC;IAC3B,QAAQ,EAAE,sBAAsB,CAAC;IACjC,MAAM,EAAE,sBAAsB,CAAC;IAC/B,MAAM,EAAE,sBAAsB,CAAC;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,mBAAmB,CAAC;IAC5B,UAAU,EAAE,kBAAkB,CAAC;IAC/B,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { InnoVintError } from './response.ts';
|
|
2
|
+
export declare class InnoVintException extends Error {
|
|
3
|
+
errors: InnoVintError[];
|
|
4
|
+
constructor(message: string, errors: InnoVintError[]);
|
|
5
|
+
}
|
|
6
|
+
export declare class InnoVintNotFoundException extends InnoVintException {
|
|
7
|
+
constructor(message: string);
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=exception.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"exception.d.ts","sourceRoot":"","sources":["../src/exception.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAE9C,qBAAa,iBAAkB,SAAQ,KAAK;IAC1C,MAAM,EAAE,aAAa,EAAE,CAAC;gBAEZ,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,aAAa,EAAE;CAKrD;AAED,qBAAa,yBAA0B,SAAQ,iBAAiB;gBAClD,OAAO,EAAE,MAAM;CAI5B"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,gBAAgB,MAAM,gBAAgB,CAAC;AAE9C,OAAO,EAAE,gBAAgB,EAAE,CAAC"}
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
class r extends Error {
|
|
2
|
+
errors;
|
|
3
|
+
constructor(t, e) {
|
|
4
|
+
super(t), this.name = "InnoVintException", this.errors = e;
|
|
5
|
+
}
|
|
6
|
+
}
|
|
7
|
+
class o extends r {
|
|
8
|
+
constructor(t) {
|
|
9
|
+
super(t, []), this.name = "InnoVintNotFoundException";
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
class c {
|
|
13
|
+
baseUrl = "";
|
|
14
|
+
// Override in subclasses
|
|
15
|
+
accessToken;
|
|
16
|
+
// InnoVint PAT
|
|
17
|
+
wineryId;
|
|
18
|
+
// InnoVint Winery ID
|
|
19
|
+
// Make a new API client for a winery; accessToken and wineryId are required
|
|
20
|
+
constructor({
|
|
21
|
+
accessToken: t,
|
|
22
|
+
wineryId: e
|
|
23
|
+
}) {
|
|
24
|
+
if (!t) throw new Error("Access token is required");
|
|
25
|
+
if (!e) throw new Error("Winery ID is required");
|
|
26
|
+
this.accessToken = t, this.wineryId = e;
|
|
27
|
+
}
|
|
28
|
+
// Make an HTTP GET to a url using our token and parse the JSON response
|
|
29
|
+
async authenticatedGet(t) {
|
|
30
|
+
const e = await fetch(t, {
|
|
31
|
+
method: "get",
|
|
32
|
+
headers: {
|
|
33
|
+
Authorization: `Access-Token ${this.accessToken}`,
|
|
34
|
+
Accept: "application/json"
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
if (!e.ok) {
|
|
38
|
+
const s = await e.json();
|
|
39
|
+
throw new r(
|
|
40
|
+
"InnoVint API request failed",
|
|
41
|
+
s.errors
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
return await e.json();
|
|
45
|
+
}
|
|
46
|
+
// Convert an endpoint and some GET params into a full URL
|
|
47
|
+
pathToUrl(t, e = {}) {
|
|
48
|
+
return `${this.baseUrl}/wineries/${this.wineryId}/${t}?${this.paramsToQuery(e)}`;
|
|
49
|
+
}
|
|
50
|
+
// Generate a querystring like 'a=b&c=d' from an object's keys and values
|
|
51
|
+
paramsToQuery(t) {
|
|
52
|
+
return Object.entries(t).map(([e, s]) => `${encodeURIComponent(e)}=${encodeURIComponent(s)}`).join("&");
|
|
53
|
+
}
|
|
54
|
+
// Make a list request and return the data for all items
|
|
55
|
+
async paginatedGet(t, e = {}) {
|
|
56
|
+
e.limit = e.limit || 200;
|
|
57
|
+
let s = [], a, n = await this.authenticatedGet(
|
|
58
|
+
this.pathToUrl(t, e)
|
|
59
|
+
);
|
|
60
|
+
for (s = this.getResultData(n), n.pagination && (a = n.pagination.next); a; )
|
|
61
|
+
n = await this.authenticatedGet(
|
|
62
|
+
a
|
|
63
|
+
), s = s.concat(this.getResultData(n)), n.pagination && (a = n.pagination.next);
|
|
64
|
+
return s;
|
|
65
|
+
}
|
|
66
|
+
// Fetch the data for each item from the list response
|
|
67
|
+
getResultData(t) {
|
|
68
|
+
return t.results.map((e) => e.data);
|
|
69
|
+
}
|
|
70
|
+
// Make a request for a single item and return just that item's data
|
|
71
|
+
async singleGet(t, e) {
|
|
72
|
+
return (await this.authenticatedGet(
|
|
73
|
+
this.pathToUrl(`${t}/${e}`)
|
|
74
|
+
)).data;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
class l extends c {
|
|
78
|
+
baseUrl = "https://sutter.innovint.us/api/v1";
|
|
79
|
+
// Get all vessels with optional filtering params
|
|
80
|
+
// By default, do not return archived vessels
|
|
81
|
+
async getVessels(t = {}) {
|
|
82
|
+
const e = { archived: !1 };
|
|
83
|
+
return await this.paginatedGet("vessels", { ...e, ...t });
|
|
84
|
+
}
|
|
85
|
+
// Get a vessel by its ID
|
|
86
|
+
async getVessel(t) {
|
|
87
|
+
return await this.singleGet("vessels", t);
|
|
88
|
+
}
|
|
89
|
+
// Get the first vessel with the given code; throw an error if not found
|
|
90
|
+
async getVesselByCode(t) {
|
|
91
|
+
const s = (await this.paginatedGet("vessels", { codeIn: t }))[0];
|
|
92
|
+
if (!s)
|
|
93
|
+
throw new o(`Vessel code not found: ${t}`);
|
|
94
|
+
return s;
|
|
95
|
+
}
|
|
96
|
+
// Get all vessels for a given lot code
|
|
97
|
+
// First fetch the lot to get its ID, then fetch vessels by lot ID
|
|
98
|
+
async getVesselsByLotCode(t) {
|
|
99
|
+
const e = await this.getLotByCode(t);
|
|
100
|
+
return await this.paginatedGet("vessels", { lotIn: e.id });
|
|
101
|
+
}
|
|
102
|
+
// Get vessels matching params that belong to a given owner
|
|
103
|
+
async getVesselsByOwner(t, e = {}) {
|
|
104
|
+
return (await this.getVessels(e)).filter((a) => a.access.ownerTags.some((n) => n.name === t));
|
|
105
|
+
}
|
|
106
|
+
// Get all lots with optional filtering params
|
|
107
|
+
async getLots(t = {}) {
|
|
108
|
+
const e = { archived: !1 };
|
|
109
|
+
return await this.paginatedGet(
|
|
110
|
+
"lots",
|
|
111
|
+
{ ...e, ...t }
|
|
112
|
+
);
|
|
113
|
+
}
|
|
114
|
+
// Get lots matching params that belong to a given owner
|
|
115
|
+
async getLotsByOwner(t, e = {}) {
|
|
116
|
+
return (await this.getLots(e)).filter((a) => a.access.ownerTags.some((n) => n.name === t));
|
|
117
|
+
}
|
|
118
|
+
// Get a lot by its ID
|
|
119
|
+
async getLot(t) {
|
|
120
|
+
return await this.singleGet("lots", t);
|
|
121
|
+
}
|
|
122
|
+
// Get the first lot with the given code; throw an error if not found
|
|
123
|
+
async getLotByCode(t) {
|
|
124
|
+
const s = (await this.paginatedGet("lots", { codeIn: t }))[0];
|
|
125
|
+
if (!s)
|
|
126
|
+
throw new o(`Lot code not found: ${t}`);
|
|
127
|
+
return s;
|
|
128
|
+
}
|
|
129
|
+
// Get all analysis data (flattening if multiple per action)
|
|
130
|
+
// By default, ignore deleted and sort with most recent effective first
|
|
131
|
+
async getAnalyses(t = {}) {
|
|
132
|
+
const e = {
|
|
133
|
+
state: "ACTIVE,EDITED",
|
|
134
|
+
sortBy: "-effectiveAt"
|
|
135
|
+
};
|
|
136
|
+
return (await this.paginatedGet("actions/analysisActions", {
|
|
137
|
+
...e,
|
|
138
|
+
...t
|
|
139
|
+
})).flatMap((a) => a.analyses);
|
|
140
|
+
}
|
|
141
|
+
// Get all addition actions
|
|
142
|
+
// By default, ignore deleted and sort with most recent effective first
|
|
143
|
+
async getAdditionActions(t = {}) {
|
|
144
|
+
const e = {
|
|
145
|
+
state: "ACTIVE,EDITED",
|
|
146
|
+
sortBy: "-effectiveAt"
|
|
147
|
+
};
|
|
148
|
+
return await this.paginatedGet("additionActions", {
|
|
149
|
+
...e,
|
|
150
|
+
...t
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
export {
|
|
155
|
+
l as InnoVintClientV1
|
|
156
|
+
};
|
|
157
|
+
//# sourceMappingURL=innovint-client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"innovint-client.js","sources":["../src/exception.ts","../src/client/base.ts","../src/client/v1.ts"],"sourcesContent":["import { InnoVintError } from \"./response.ts\";\n\nexport class InnoVintException extends Error {\n errors: InnoVintError[];\n\n constructor(message: string, errors: InnoVintError[]) {\n super(message);\n this.name = \"InnoVintException\";\n this.errors = errors;\n }\n}\n\nexport class InnoVintNotFoundException extends InnoVintException {\n constructor(message: string) {\n super(message, []);\n this.name = \"InnoVintNotFoundException\";\n }\n}\n","import { InnoVintRequestParams } from \"../request.ts\";\nimport {\n InnoVintListResponse,\n InnoVintErrorResponse,\n InnoVintData,\n} from \"../response.ts\";\nimport { InnoVintException } from \"../exception.ts\";\n\n// Base class for InnoVint API clients\nexport default abstract class InnoVintClientBase {\n protected readonly baseUrl: string = \"\"; // Override in subclasses\n protected readonly accessToken: string; // InnoVint PAT\n protected readonly wineryId: string; // InnoVint Winery ID\n\n // Make a new API client for a winery; accessToken and wineryId are required\n constructor({\n accessToken,\n wineryId,\n }: {\n accessToken: string;\n wineryId: string;\n }) {\n if (!accessToken) throw new Error(\"Access token is required\");\n if (!wineryId) throw new Error(\"Winery ID is required\");\n\n this.accessToken = accessToken;\n this.wineryId = wineryId;\n }\n\n // Make an HTTP GET to a url using our token and parse the JSON response\n protected async authenticatedGet<T>(\n url: string,\n ): Promise<\n InnoVintListResponse<T> | InnoVintData<T> | InnoVintErrorResponse\n > {\n const response = await fetch(url, {\n method: \"get\",\n headers: {\n Authorization: `Access-Token ${this.accessToken}`,\n Accept: \"application/json\",\n },\n });\n\n if (!response.ok) {\n const errorResponse = (await response.json()) as InnoVintErrorResponse;\n throw new InnoVintException(\n \"InnoVint API request failed\",\n errorResponse.errors,\n );\n }\n\n return (await response.json()) as InnoVintListResponse<T> | InnoVintData<T>;\n }\n\n // Convert an endpoint and some GET params into a full URL\n protected pathToUrl(path: string, params: InnoVintRequestParams = {}) {\n return `${this.baseUrl}/wineries/${this.wineryId}/${path}?${this.paramsToQuery(params)}`;\n }\n\n // Generate a querystring like 'a=b&c=d' from an object's keys and values\n protected paramsToQuery(params: object) {\n return Object.entries(params)\n .map(([k, v]) => `${encodeURIComponent(k)}=${encodeURIComponent(v)}`)\n .join(\"&\");\n }\n\n // Make a list request and return the data for all items\n protected async paginatedGet<T, R extends InnoVintRequestParams>(\n path: string,\n params: R = {} as R,\n ) {\n // Ask for the max items per page (200), unless we specified something else\n params.limit = params.limit || 200;\n\n // Get the first response and check if there are more pages\n let results: T[] = [];\n let nextPageUrl;\n let response = (await this.authenticatedGet<T>(\n this.pathToUrl(path, params),\n )) as InnoVintListResponse<T>;\n results = this.getResultData(response);\n if (response.pagination) nextPageUrl = response.pagination.next;\n\n // As long as there are more pages, keep visiting them and adding their results\n while (nextPageUrl) {\n response = (await this.authenticatedGet<T>(\n nextPageUrl,\n )) as InnoVintListResponse<T>;\n results = results.concat(this.getResultData(response));\n if (response.pagination) nextPageUrl = response.pagination.next;\n }\n\n // return all the collected results at the end\n return results;\n }\n\n // Fetch the data for each item from the list response\n protected getResultData<T>(response: InnoVintListResponse<T>): T[] {\n return response.results.map((item) => item.data);\n }\n\n // Make a request for a single item and return just that item's data\n protected async singleGet<T>(path: string, id: string) {\n const response = (await this.authenticatedGet<T>(\n this.pathToUrl(`${path}/${id}`),\n )) as InnoVintData<T>;\n return response.data;\n }\n}\n","import InnoVintClientBase from \"./base.ts\";\nimport {\n InnoVintVesselsRequestParams,\n InnoVintLotsRequestParams,\n InnoVintActionsRequestParams,\n} from \"../request.ts\";\nimport InnoVintLot from \"../data/lot.ts\";\nimport InnoVintVessel from \"../data/vessel.ts\";\nimport {\n InnoVintAnalysisAction,\n InnoVintAnalysis,\n} from \"../data/action/analysis.ts\";\nimport { InnoVintNotFoundException } from \"../exception.ts\";\nimport { InnoVintAdditionAction } from \"../data/action/addition.ts\";\n\n// The public v1 InnoVint API\nexport default class InnoVintClientV1 extends InnoVintClientBase {\n protected readonly baseUrl = \"https://sutter.innovint.us/api/v1\";\n\n // Get all vessels with optional filtering params\n // By default, do not return archived vessels\n async getVessels(\n params: InnoVintVesselsRequestParams = {},\n ): Promise<InnoVintVessel[]> {\n const defaultParams = { archived: false };\n return await this.paginatedGet<\n InnoVintVessel,\n InnoVintVesselsRequestParams\n >(\"vessels\", { ...defaultParams, ...params });\n }\n\n // Get a vessel by its ID\n async getVessel(id: string): Promise<InnoVintVessel> {\n return await this.singleGet<InnoVintVessel>(\"vessels\", id);\n }\n\n // Get the first vessel with the given code; throw an error if not found\n async getVesselByCode(code: string): Promise<InnoVintVessel> {\n const vessels = await this.paginatedGet<\n InnoVintVessel,\n InnoVintVesselsRequestParams\n >(\"vessels\", { codeIn: code });\n const result = vessels[0];\n if (!result)\n throw new InnoVintNotFoundException(`Vessel code not found: ${code}`);\n return result;\n }\n\n // Get all vessels for a given lot code\n // First fetch the lot to get its ID, then fetch vessels by lot ID\n async getVesselsByLotCode(lotCode: string): Promise<InnoVintVessel[]> {\n const lot = await this.getLotByCode(lotCode);\n return await this.paginatedGet<\n InnoVintVessel,\n InnoVintVesselsRequestParams\n >(\"vessels\", { lotIn: lot.id });\n }\n\n // Get vessels matching params that belong to a given owner\n async getVesselsByOwner(\n ownerName: string,\n params: InnoVintVesselsRequestParams = {},\n ): Promise<InnoVintVessel[]> {\n const allVessels = await this.getVessels(params);\n return allVessels.filter((vessel) => vessel.access.ownerTags.some((tag) => tag.name === ownerName));\n }\n\n // Get all lots with optional filtering params\n async getLots(\n params: InnoVintLotsRequestParams = {},\n ): Promise<InnoVintLot[]> {\n const defaultParams = { archived: false };\n return await this.paginatedGet<InnoVintLot, InnoVintLotsRequestParams>(\n \"lots\",\n { ...defaultParams, ...params },\n );\n }\n\n // Get lots matching params that belong to a given owner\n async getLotsByOwner(\n ownerName: string,\n params: InnoVintLotsRequestParams = {},\n ): Promise<InnoVintLot[]> {\n const allLots = await this.getLots(params);\n return allLots.filter((lot) => lot.access.ownerTags.some((tag) => tag.name === ownerName));\n }\n\n // Get a lot by its ID\n async getLot(id: string): Promise<InnoVintLot> {\n return await this.singleGet<InnoVintLot>(\"lots\", id);\n }\n\n // Get the first lot with the given code; throw an error if not found\n async getLotByCode(code: string): Promise<InnoVintLot> {\n const lots = await this.paginatedGet<\n InnoVintLot,\n InnoVintLotsRequestParams\n >(\"lots\", { codeIn: code });\n const result = lots[0];\n if (!result)\n throw new InnoVintNotFoundException(`Lot code not found: ${code}`);\n return result;\n }\n\n // Get all analysis data (flattening if multiple per action)\n // By default, ignore deleted and sort with most recent effective first\n async getAnalyses(\n params: InnoVintActionsRequestParams = {},\n ): Promise<InnoVintAnalysis[]> {\n const defaultParams = {\n state: \"ACTIVE,EDITED\",\n sortBy: \"-effectiveAt\" as const,\n };\n const actions = await this.paginatedGet<\n InnoVintAnalysisAction,\n InnoVintActionsRequestParams\n >(\"actions/analysisActions\", {\n ...defaultParams,\n ...params,\n });\n return actions.flatMap((action) => action.analyses);\n }\n\n // Get all addition actions\n // By default, ignore deleted and sort with most recent effective first\n async getAdditionActions(\n params: InnoVintActionsRequestParams = {},\n ): Promise<InnoVintAdditionAction[]> {\n const defaultParams = {\n state: \"ACTIVE,EDITED\",\n sortBy: \"-effectiveAt\" as const,\n };\n return await this.paginatedGet<\n InnoVintAdditionAction,\n InnoVintActionsRequestParams\n >(\"additionActions\", {\n ...defaultParams,\n ...params,\n });\n }\n}\n"],"names":["InnoVintException","message","errors","InnoVintNotFoundException","InnoVintClientBase","accessToken","wineryId","url","response","errorResponse","path","params","k","v","results","nextPageUrl","item","id","InnoVintClientV1","defaultParams","code","result","lotCode","lot","ownerName","vessel","tag","action"],"mappings":"AAEO,MAAMA,UAA0B,MAAM;AAAA,EAC3C;AAAA,EAEA,YAAYC,GAAiBC,GAAyB;AACpD,UAAMD,CAAO,GACb,KAAK,OAAO,qBACZ,KAAK,SAASC;AAAA,EAChB;AACF;AAEO,MAAMC,UAAkCH,EAAkB;AAAA,EAC/D,YAAYC,GAAiB;AAC3B,UAAMA,GAAS,EAAE,GACjB,KAAK,OAAO;AAAA,EACd;AACF;ACRA,MAA8BG,EAAmB;AAAA,EAC5B,UAAkB;AAAA;AAAA,EAClB;AAAA;AAAA,EACA;AAAA;AAAA;AAAA,EAGnB,YAAY;AAAA,IACV,aAAAC;AAAA,IACA,UAAAC;AAAA,EAAA,GAIC;AACD,QAAI,CAACD,EAAa,OAAM,IAAI,MAAM,0BAA0B;AAC5D,QAAI,CAACC,EAAU,OAAM,IAAI,MAAM,uBAAuB;AAEtD,SAAK,cAAcD,GACnB,KAAK,WAAWC;AAAA,EAClB;AAAA;AAAA,EAGA,MAAgB,iBACdC,GAGA;AACA,UAAMC,IAAW,MAAM,MAAMD,GAAK;AAAA,MAChC,QAAQ;AAAA,MACR,SAAS;AAAA,QAC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B,YADgB,MAAM,KAAK,QAAQA,CAAM,GAC1B,OAAO,CAACY,MAAQA,EAAI,OAAO,UAAU,KAAK,CAACG,MAAQA,EAAI,SAASF,CAAS,CAAC;AAAA,EAC3F;AAAA;AAAA,EAGA,MAAM,OAAOP,GAAkC;AAC7C,WAAO,MAAM,KAAK,UAAuB,QAAQA,CAAE;AAAA,EACrD;AAAA;AAAA,EAGA,MAAM,aAAaG,GAAoC;AAKrD,UAAMC,KAJO,MAAM,KAAK,aAGtB,QAAQ,EAAE,QAAQD,GAAM,GACN,CAAC;AACrB,QAAI,CAACC;AACH,YAAM,IAAIlB,EAA0B,uBAAuBiB,CAAI,EAAE;AACnE,WAAOC;AAAA,EACT;AAAA;AAAA;AAAA,EAIA,MAAM,YACJV,IAAuC,IACV;AAC7B,UAAMQ,IAAgB;AAAA,MACpB,OAAO;AAAA,MACP,QAAQ;AAAA,IAAA;AASV,YAPgB,MAAM,KAAK,aAGzB,2BAA2B;AAAA,MAC3B,GAAGA;AAAA,MACH,GAAGR;AAAA,IAAA,CACJ,GACc,QAAQ,CAACgB,MAAWA,EAAO,QAAQ;AAAA,EACpD;AAAA;AAAA;AAAA,EAIA,MAAM,mBACJhB,IAAuC,IACJ;AACnC,UAAMQ,IAAgB;AAAA,MACpB,OAAO;AAAA,MACP,QAAQ;AAAA,IAAA;AAEV,WAAO,MAAM,KAAK,aAGhB,mBAAmB;AAAA,MACnB,GAAGA;AAAA,MACH,GAAGR;AAAA,IAAA,CACJ;AAAA,EACH;AACF;"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
(function(i,o){typeof exports=="object"&&typeof module<"u"?o(exports):typeof define=="function"&&define.amd?define(["exports"],o):(i=typeof globalThis<"u"?globalThis:i||self,o(i["innovint-client"]={}))})(this,(function(i){"use strict";class o extends Error{errors;constructor(t,e){super(t),this.name="InnoVintException",this.errors=e}}class c extends o{constructor(t){super(t,[]),this.name="InnoVintNotFoundException"}}class l{baseUrl="";accessToken;wineryId;constructor({accessToken:t,wineryId:e}){if(!t)throw new Error("Access token is required");if(!e)throw new Error("Winery ID is required");this.accessToken=t,this.wineryId=e}async authenticatedGet(t){const e=await fetch(t,{method:"get",headers:{Authorization:`Access-Token ${this.accessToken}`,Accept:"application/json"}});if(!e.ok){const s=await e.json();throw new o("InnoVint API request failed",s.errors)}return await e.json()}pathToUrl(t,e={}){return`${this.baseUrl}/wineries/${this.wineryId}/${t}?${this.paramsToQuery(e)}`}paramsToQuery(t){return Object.entries(t).map(([e,s])=>`${encodeURIComponent(e)}=${encodeURIComponent(s)}`).join("&")}async paginatedGet(t,e={}){e.limit=e.limit||200;let s=[],a,n=await this.authenticatedGet(this.pathToUrl(t,e));for(s=this.getResultData(n),n.pagination&&(a=n.pagination.next);a;)n=await this.authenticatedGet(a),s=s.concat(this.getResultData(n)),n.pagination&&(a=n.pagination.next);return s}getResultData(t){return t.results.map(e=>e.data)}async singleGet(t,e){return(await this.authenticatedGet(this.pathToUrl(`${t}/${e}`))).data}}class d extends l{baseUrl="https://sutter.innovint.us/api/v1";async getVessels(t={}){const e={archived:!1};return await this.paginatedGet("vessels",{...e,...t})}async getVessel(t){return await this.singleGet("vessels",t)}async getVesselByCode(t){const s=(await this.paginatedGet("vessels",{codeIn:t}))[0];if(!s)throw new c(`Vessel code not found: ${t}`);return s}async getVesselsByLotCode(t){const e=await this.getLotByCode(t);return await this.paginatedGet("vessels",{lotIn:e.id})}async getVesselsByOwner(t,e={}){return(await this.getVessels(e)).filter(a=>a.access.ownerTags.some(n=>n.name===t))}async getLots(t={}){const e={archived:!1};return await this.paginatedGet("lots",{...e,...t})}async getLotsByOwner(t,e={}){return(await this.getLots(e)).filter(a=>a.access.ownerTags.some(n=>n.name===t))}async getLot(t){return await this.singleGet("lots",t)}async getLotByCode(t){const s=(await this.paginatedGet("lots",{codeIn:t}))[0];if(!s)throw new c(`Lot code not found: ${t}`);return s}async getAnalyses(t={}){const e={state:"ACTIVE,EDITED",sortBy:"-effectiveAt"};return(await this.paginatedGet("actions/analysisActions",{...e,...t})).flatMap(a=>a.analyses)}async getAdditionActions(t={}){const e={state:"ACTIVE,EDITED",sortBy:"-effectiveAt"};return await this.paginatedGet("additionActions",{...e,...t})}}i.InnoVintClientV1=d,Object.defineProperty(i,Symbol.toStringTag,{value:"Module"})}));
|
|
2
|
+
//# sourceMappingURL=innovint-client.umd.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"innovint-client.umd.cjs","sources":["../src/exception.ts","../src/client/base.ts","../src/client/v1.ts"],"sourcesContent":["import { InnoVintError } from \"./response.ts\";\n\nexport class InnoVintException extends Error {\n errors: InnoVintError[];\n\n constructor(message: string, errors: InnoVintError[]) {\n super(message);\n this.name = \"InnoVintException\";\n this.errors = errors;\n }\n}\n\nexport class InnoVintNotFoundException extends InnoVintException {\n constructor(message: string) {\n super(message, []);\n this.name = \"InnoVintNotFoundException\";\n }\n}\n","import { InnoVintRequestParams } from \"../request.ts\";\nimport {\n InnoVintListResponse,\n InnoVintErrorResponse,\n InnoVintData,\n} from \"../response.ts\";\nimport { InnoVintException } from \"../exception.ts\";\n\n// Base class for InnoVint API clients\nexport default abstract class InnoVintClientBase {\n protected readonly baseUrl: string = \"\"; // Override in subclasses\n protected readonly accessToken: string; // InnoVint PAT\n protected readonly wineryId: string; // InnoVint Winery ID\n\n // Make a new API client for a winery; accessToken and wineryId are required\n constructor({\n accessToken,\n wineryId,\n }: {\n accessToken: string;\n wineryId: string;\n }) {\n if (!accessToken) throw new Error(\"Access token is required\");\n if (!wineryId) throw new Error(\"Winery ID is required\");\n\n this.accessToken = accessToken;\n this.wineryId = wineryId;\n }\n\n // Make an HTTP GET to a url using our token and parse the JSON response\n protected async authenticatedGet<T>(\n url: string,\n ): Promise<\n InnoVintListResponse<T> | InnoVintData<T> | InnoVintErrorResponse\n > {\n const response = await fetch(url, {\n method: \"get\",\n headers: {\n Authorization: `Access-Token ${this.accessToken}`,\n Accept: \"application/json\",\n },\n });\n\n if (!response.ok) {\n const errorResponse = (await response.json()) as InnoVintErrorResponse;\n throw new InnoVintException(\n \"InnoVint API request failed\",\n errorResponse.errors,\n );\n }\n\n return (await response.json()) as InnoVintListResponse<T> | InnoVintData<T>;\n }\n\n // Convert an endpoint and some GET params into a full URL\n protected pathToUrl(path: string, params: InnoVintRequestParams = {}) {\n return `${this.baseUrl}/wineries/${this.wineryId}/${path}?${this.paramsToQuery(params)}`;\n }\n\n // Generate a querystring like 'a=b&c=d' from an object's keys and values\n protected paramsToQuery(params: object) {\n return Object.entries(params)\n .map(([k, v]) => `${encodeURIComponent(k)}=${encodeURIComponent(v)}`)\n .join(\"&\");\n }\n\n // Make a list request and return the data for all items\n protected async paginatedGet<T, R extends InnoVintRequestParams>(\n path: string,\n params: R = {} as R,\n ) {\n // Ask for the max items per page (200), unless we specified something else\n params.limit = params.limit || 200;\n\n // Get the first response and check if there are more pages\n let results: T[] = [];\n let nextPageUrl;\n let response = (await this.authenticatedGet<T>(\n this.pathToUrl(path, params),\n )) as InnoVintListResponse<T>;\n results = this.getResultData(response);\n if (response.pagination) nextPageUrl = response.pagination.next;\n\n // As long as there are more pages, keep visiting them and adding their results\n while (nextPageUrl) {\n response = (await this.authenticatedGet<T>(\n nextPageUrl,\n )) as InnoVintListResponse<T>;\n results = results.concat(this.getResultData(response));\n if (response.pagination) nextPageUrl = response.pagination.next;\n }\n\n // return all the collected results at the end\n return results;\n }\n\n // Fetch the data for each item from the list response\n protected getResultData<T>(response: InnoVintListResponse<T>): T[] {\n return response.results.map((item) => item.data);\n }\n\n // Make a request for a single item and return just that item's data\n protected async singleGet<T>(path: string, id: string) {\n const response = (await this.authenticatedGet<T>(\n this.pathToUrl(`${path}/${id}`),\n )) as InnoVintData<T>;\n return response.data;\n }\n}\n","import InnoVintClientBase from \"./base.ts\";\nimport {\n InnoVintVesselsRequestParams,\n InnoVintLotsRequestParams,\n InnoVintActionsRequestParams,\n} from \"../request.ts\";\nimport InnoVintLot from \"../data/lot.ts\";\nimport InnoVintVessel from \"../data/vessel.ts\";\nimport {\n InnoVintAnalysisAction,\n InnoVintAnalysis,\n} from \"../data/action/analysis.ts\";\nimport { InnoVintNotFoundException } from \"../exception.ts\";\nimport { InnoVintAdditionAction } from \"../data/action/addition.ts\";\n\n// The public v1 InnoVint API\nexport default class InnoVintClientV1 extends InnoVintClientBase {\n protected readonly baseUrl = \"https://sutter.innovint.us/api/v1\";\n\n // Get all vessels with optional filtering params\n // By default, do not return archived vessels\n async getVessels(\n params: InnoVintVesselsRequestParams = {},\n ): Promise<InnoVintVessel[]> {\n const defaultParams = { archived: false };\n return await this.paginatedGet<\n InnoVintVessel,\n InnoVintVesselsRequestParams\n >(\"vessels\", { ...defaultParams, ...params });\n }\n\n // Get a vessel by its ID\n async getVessel(id: string): Promise<InnoVintVessel> {\n return await this.singleGet<InnoVintVessel>(\"vessels\", id);\n }\n\n // Get the first vessel with the given code; throw an error if not found\n async getVesselByCode(code: string): Promise<InnoVintVessel> {\n const vessels = await this.paginatedGet<\n InnoVintVessel,\n InnoVintVesselsRequestParams\n >(\"vessels\", { codeIn: code });\n const result = vessels[0];\n if (!result)\n throw new InnoVintNotFoundException(`Vessel code not found: ${code}`);\n return result;\n }\n\n // Get all vessels for a given lot code\n // First fetch the lot to get its ID, then fetch vessels by lot ID\n async getVesselsByLotCode(lotCode: string): Promise<InnoVintVessel[]> {\n const lot = await this.getLotByCode(lotCode);\n return await this.paginatedGet<\n InnoVintVessel,\n InnoVintVesselsRequestParams\n >(\"vessels\", { lotIn: lot.id });\n }\n\n // Get vessels matching params that belong to a given owner\n async getVesselsByOwner(\n ownerName: string,\n params: InnoVintVesselsRequestParams = {},\n ): Promise<InnoVintVessel[]> {\n const allVessels = await this.getVessels(params);\n return allVessels.filter((vessel) => vessel.access.ownerTags.some((tag) => tag.name === ownerName));\n }\n\n // Get all lots with optional filtering params\n async getLots(\n params: InnoVintLotsRequestParams = {},\n ): Promise<InnoVintLot[]> {\n const defaultParams = { archived: false };\n return await this.paginatedGet<InnoVintLot, InnoVintLotsRequestParams>(\n \"lots\",\n { ...defaultParams, ...params },\n );\n }\n\n // Get lots matching params that belong to a given owner\n async getLotsByOwner(\n ownerName: string,\n params: InnoVintLotsRequestParams = {},\n ): Promise<InnoVintLot[]> {\n const allLots = await this.getLots(params);\n return allLots.filter((lot) => lot.access.ownerTags.some((tag) => tag.name === ownerName));\n }\n\n // Get a lot by its ID\n async getLot(id: string): Promise<InnoVintLot> {\n return await this.singleGet<InnoVintLot>(\"lots\", id);\n }\n\n // Get the first lot with the given code; throw an error if not found\n async getLotByCode(code: string): Promise<InnoVintLot> {\n const lots = await this.paginatedGet<\n InnoVintLot,\n InnoVintLotsRequestParams\n >(\"lots\", { codeIn: code });\n const result = lots[0];\n if (!result)\n throw new InnoVintNotFoundException(`Lot code not found: ${code}`);\n return result;\n }\n\n // Get all analysis data (flattening if multiple per action)\n // By default, ignore deleted and sort with most recent effective first\n async getAnalyses(\n params: InnoVintActionsRequestParams = {},\n ): Promise<InnoVintAnalysis[]> {\n const defaultParams = {\n state: \"ACTIVE,EDITED\",\n sortBy: \"-effectiveAt\" as const,\n };\n const actions = await this.paginatedGet<\n InnoVintAnalysisAction,\n InnoVintActionsRequestParams\n >(\"actions/analysisActions\", {\n ...defaultParams,\n ...params,\n });\n return actions.flatMap((action) => action.analyses);\n }\n\n // Get all addition actions\n // By default, ignore deleted and sort with most recent effective first\n async getAdditionActions(\n params: InnoVintActionsRequestParams = {},\n ): Promise<InnoVintAdditionAction[]> {\n const defaultParams = {\n state: \"ACTIVE,EDITED\",\n sortBy: \"-effectiveAt\" as const,\n };\n return await this.paginatedGet<\n InnoVintAdditionAction,\n InnoVintActionsRequestParams\n >(\"additionActions\", {\n ...defaultParams,\n ...params,\n });\n }\n}\n"],"names":["InnoVintException","message","errors","InnoVintNotFoundException","InnoVintClientBase","accessToken","wineryId","url","response","errorResponse","path","params","k","v","results","nextPageUrl","item","id","InnoVintClientV1","defaultParams","code","result","lotCode","lot","own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UAAU,KAAMC,GAAQA,EAAI,OAASF,CAAS,CAAC,CACpG,CAGA,MAAM,QACJb,EAAoC,GACZ,CACxB,MAAMQ,EAAgB,CAAE,SAAU,EAAA,EAClC,OAAO,MAAM,KAAK,aAChB,OACA,CAAE,GAAGA,EAAe,GAAGR,CAAA,CAAO,CAElC,CAGA,MAAM,eACJa,EACAb,EAAoC,GACZ,CAExB,OADgB,MAAM,KAAK,QAAQA,CAAM,GAC1B,OAAQY,GAAQA,EAAI,OAAO,UAAU,KAAMG,GAAQA,EAAI,OAASF,CAAS,CAAC,CAC3F,CAGA,MAAM,OAAOP,EAAkC,CAC7C,OAAO,MAAM,KAAK,UAAuB,OAAQA,CAAE,CACrD,CAGA,MAAM,aAAaG,EAAoC,CAKrD,MAAMC,GAJO,MAAM,KAAK,aAGtB,OAAQ,CAAE,OAAQD,EAAM,GACN,CAAC,EACrB,GAAI,CAACC,EACH,MAAM,IAAIlB,EAA0B,uBAAuBiB,CAAI,EAAE,EACnE,OAAOC,CACT,CAIA,MAAM,YACJV,EAAuC,GACV,CAC7B,MAAMQ,EAAgB,CACpB,MAAO,gBACP,OAAQ,cAAA,EASV,OAPgB,MAAM,KAAK,aAGzB,0BAA2B,CAC3B,GAAGA,EACH,GAAGR,CAAA,CACJ,GACc,QAASgB,GAAWA,EAAO,QAAQ,CACpD,CAIA,MAAM,mBACJhB,EAAuC,GACJ,CACnC,MAAMQ,EAAgB,CACpB,MAAO,gBACP,OAAQ,cAAA,EAEV,OAAO,MAAM,KAAK,aAGhB,kBAAmB,CACnB,GAAGA,EACH,GAAGR,CAAA,CACJ,CACH,CACF"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
export interface InnoVintRequestParams {
|
|
2
|
+
limit?: number;
|
|
3
|
+
offset?: number;
|
|
4
|
+
}
|
|
5
|
+
export interface InnoVintVesselsRequestParams extends InnoVintRequestParams {
|
|
6
|
+
archived?: boolean;
|
|
7
|
+
codeIn?: string;
|
|
8
|
+
lotIn?: string;
|
|
9
|
+
idIn?: string;
|
|
10
|
+
q?: string;
|
|
11
|
+
}
|
|
12
|
+
export interface InnoVintLotsRequestParams extends InnoVintRequestParams {
|
|
13
|
+
archived?: boolean;
|
|
14
|
+
bondIn?: string;
|
|
15
|
+
codeIn?: string;
|
|
16
|
+
idIn?: string;
|
|
17
|
+
q?: string;
|
|
18
|
+
updatedAtAfter?: string;
|
|
19
|
+
updatedAtBefore?: string;
|
|
20
|
+
}
|
|
21
|
+
type InnoVintActionsSort = "-createdAt" | "-deletedAt" | "-effectiveAt" | "-id" | "-updatedAt" | "createdAt" | "deletedAt" | "effectiveAt" | "id" | "updatedAt";
|
|
22
|
+
export interface InnoVintActionsRequestParams extends InnoVintRequestParams {
|
|
23
|
+
createdAtAfter?: string;
|
|
24
|
+
createdAtBefore?: string;
|
|
25
|
+
deletedAtAfter?: string;
|
|
26
|
+
deletedAtBefore?: string;
|
|
27
|
+
effectiveAtAfter?: string;
|
|
28
|
+
effectiveAtBefore?: string;
|
|
29
|
+
updatedAtAfter?: string;
|
|
30
|
+
updatedAtBefore?: string;
|
|
31
|
+
id?: string;
|
|
32
|
+
referenceNumber?: string;
|
|
33
|
+
sort?: InnoVintActionsSort;
|
|
34
|
+
state?: string;
|
|
35
|
+
}
|
|
36
|
+
export {};
|
|
37
|
+
//# sourceMappingURL=request.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"request.d.ts","sourceRoot":"","sources":["../src/request.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,qBAAqB;IACpC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,4BAA6B,SAAQ,qBAAqB;IACzE,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,CAAC,CAAC,EAAE,MAAM,CAAC;CACZ;AAED,MAAM,WAAW,yBAA0B,SAAQ,qBAAqB;IACtE,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,CAAC,CAAC,EAAE,MAAM,CAAC;IACX,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED,KAAK,mBAAmB,GACpB,YAAY,GACZ,YAAY,GACZ,cAAc,GACd,KAAK,GACL,YAAY,GACZ,WAAW,GACX,WAAW,GACX,aAAa,GACb,IAAI,GACJ,WAAW,CAAC;AAGhB,MAAM,WAAW,4BAA6B,SAAQ,qBAAqB;IACzE,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,IAAI,CAAC,EAAE,mBAAmB,CAAC;IAC3B,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export interface InnoVintData<T> {
|
|
2
|
+
data: T;
|
|
3
|
+
relationships: object;
|
|
4
|
+
}
|
|
5
|
+
export interface InnoVintListResponse<T> {
|
|
6
|
+
pagination: {
|
|
7
|
+
count: number;
|
|
8
|
+
next?: string;
|
|
9
|
+
previous?: string;
|
|
10
|
+
};
|
|
11
|
+
results: InnoVintData<T>[];
|
|
12
|
+
}
|
|
13
|
+
export interface InnoVintError {
|
|
14
|
+
code: string;
|
|
15
|
+
details: string;
|
|
16
|
+
metadata: object;
|
|
17
|
+
}
|
|
18
|
+
export interface InnoVintErrorResponse {
|
|
19
|
+
errors: InnoVintError[];
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=response.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"response.d.ts","sourceRoot":"","sources":["../src/response.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,YAAY,CAAC,CAAC;IAC7B,IAAI,EAAE,CAAC,CAAC;IACR,aAAa,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,oBAAoB,CAAC,CAAC;IACrC,UAAU,EAAE;QACV,KAAK,EAAE,MAAM,CAAC;QACd,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,QAAQ,CAAC,EAAE,MAAM,CAAC;KACnB,CAAC;IACF,OAAO,EAAE,YAAY,CAAC,CAAC,CAAC,EAAE,CAAC;CAC5B;AAED,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,qBAAqB;IACpC,MAAM,EAAE,aAAa,EAAE,CAAC;CACzB"}
|
package/package.json
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "innovint-client",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "API client for InnoVint",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"files": [
|
|
7
|
+
"dist"
|
|
8
|
+
],
|
|
9
|
+
"main": "./dist/innovint-client.umd.cjs",
|
|
10
|
+
"module": "./dist/innovint-client.js",
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"exports": {
|
|
13
|
+
".": {
|
|
14
|
+
"import": "./dist/innovint-client.js",
|
|
15
|
+
"require": "./dist/innovint-client.umd.cjs"
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
"scripts": {
|
|
19
|
+
"dev": "vite",
|
|
20
|
+
"build": "vite build",
|
|
21
|
+
"test": "vitest",
|
|
22
|
+
"typecheck": "tsc --noEmit",
|
|
23
|
+
"lint": "prettier --check .",
|
|
24
|
+
"format": "prettier --write ."
|
|
25
|
+
},
|
|
26
|
+
"keywords": [
|
|
27
|
+
"innovint",
|
|
28
|
+
"wine",
|
|
29
|
+
"api"
|
|
30
|
+
],
|
|
31
|
+
"author": {
|
|
32
|
+
"name": "Nick Budak",
|
|
33
|
+
"email": "nick@solanus.systems"
|
|
34
|
+
},
|
|
35
|
+
"license": "MIT",
|
|
36
|
+
"devDependencies": {
|
|
37
|
+
"@msw/source": "^0.6.0",
|
|
38
|
+
"@mswjs/interceptors": "^0.40.0",
|
|
39
|
+
"@types/node": "^25.0.10",
|
|
40
|
+
"prettier": "^3.8.1",
|
|
41
|
+
"typescript": "^5.9.3",
|
|
42
|
+
"vite": "^7.3.1",
|
|
43
|
+
"vite-plugin-dts": "^4.5.4",
|
|
44
|
+
"vitest": "^4.0.18"
|
|
45
|
+
}
|
|
46
|
+
}
|