Skip to content

Commit

Permalink
added note to use v5.7.0 in the interim
Browse files Browse the repository at this point in the history
  • Loading branch information
tk26 committed Dec 6, 2023
1 parent 275e4d1 commit bb0c4f7
Show file tree
Hide file tree
Showing 61 changed files with 3,420 additions and 0 deletions.
4 changes: 4 additions & 0 deletions README.md
Expand Up @@ -9,6 +9,10 @@ This is the official node.js module for sending notifications with node.js with

## Installation (via [npm](https://www.npmjs.com/package/@trycourier/courier))

### Note

Recent version v6 can be unstable, its recommended to use version `v5.7.0`. We are actively working on making v6 stable and will be updating the README accordingly soon.

```bash
npm install @trycourier/courier
```
Expand Down
13 changes: 13 additions & 0 deletions lib/audiences/index.d.ts
@@ -0,0 +1,13 @@
import { ICourierClientConfiguration } from "../types";
import * as AudienceTypes from "./types";
export declare const audiences: (options: ICourierClientConfiguration) => {
delete: (audienceId: string) => Promise<void>;
get: (audienceId: string) => Promise<AudienceTypes.IAudience>;
listAudiences: (params?: {
cursor: string;
} | undefined) => Promise<AudienceTypes.IAudienceListResponse>;
listMembers: (audienceId: string, params?: {
cursor: string;
} | undefined) => Promise<AudienceTypes.IAudienceMemberListResponse>;
put: (audience: Omit<AudienceTypes.IAudience, "created_at" | "updated_at">) => Promise<AudienceTypes.IAudience>;
};
108 changes: 108 additions & 0 deletions lib/audiences/index.js
@@ -0,0 +1,108 @@
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.audiences = void 0;
var deleteAudience = function (options) { return function (audienceId) { return __awaiter(void 0, void 0, void 0, function () {
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, options.httpClient.delete("/audiences/" + audienceId)];
case 1:
_a.sent();
return [2 /*return*/];
}
});
}); }; };
var getAudience = function (options) {
return function (audienceId) { return __awaiter(void 0, void 0, void 0, function () {
var response;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, options.httpClient.get("/audiences/" + audienceId)];
case 1:
response = _a.sent();
return [2 /*return*/, response.data.audience];
}
});
}); };
};
var listAudiences = function (options) {
return function (params) { return __awaiter(void 0, void 0, void 0, function () {
var response;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, options.httpClient.get("/audiences", params)];
case 1:
response = _a.sent();
return [2 /*return*/, response.data];
}
});
}); };
};
var listMembers = function (options) {
return function (audienceId, params) { return __awaiter(void 0, void 0, void 0, function () {
var response;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, options.httpClient.get("/audiences/" + audienceId + "/members", params)];
case 1:
response = _a.sent();
return [2 /*return*/, response.data];
}
});
}); };
};
var putAudience = function (options) {
return function (audience) { return __awaiter(void 0, void 0, void 0, function () {
var response;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, options.httpClient.put("/audiences/" + audience.id, audience)];
case 1:
response = _a.sent();
return [2 /*return*/, response.data.audience];
}
});
}); };
};
exports.audiences = function (options) { return ({
delete: deleteAudience(options),
get: getAudience(options),
listAudiences: listAudiences(options),
listMembers: listMembers(options),
put: putAudience(options)
}); };
65 changes: 65 additions & 0 deletions lib/audiences/types.d.ts
@@ -0,0 +1,65 @@
export declare type ComparisonOperator = "EQ" | "GT" | "GTE" | "INCLUDES" | "LT" | "LTE" | "NEQ" | "OMIT";
export declare type LogicalOperator = "AND" | "OR";
export declare type Operator = ComparisonOperator | LogicalOperator;
declare type Without<T, U> = {
[P in Exclude<keyof T, keyof U>]?: never;
};
declare type XOR<T, U> = T | U extends object ? (Without<T, U> & U) | (Without<U, T> & T) : T | U;
interface IBaseFilterConfig {
operator: Operator;
}
interface ISingleFilterConfig extends IBaseFilterConfig {
path: string;
value: string;
}
interface INestedFilterConfig extends IBaseFilterConfig {
rules: FilterConfig[];
}
export declare type FilterConfig = XOR<ISingleFilterConfig, INestedFilterConfig>;
export interface IAudience {
created_at: string;
description?: string;
id: string;
name?: string;
filter: FilterConfig;
updated_at: string;
}
export interface IAudienceMember {
added_at: string;
audience_id: string;
audience_version: number;
member_id: string;
reason: string;
}
export interface IAudienceListResponse {
items: IAudience[];
paging: {
cursor: string;
more: boolean;
};
}
export interface IAudienceMemberGetResponse {
audienceMember: IAudienceMember;
}
export interface IAudienceMemberListResponse {
items: IAudienceMember[];
paging: {
cursor: string;
more: boolean;
};
}
export interface IAudiencePutResponse {
audience: IAudience;
}
export interface ICourierClientAudiences {
delete: (id: string) => Promise<void>;
get: (id: string) => Promise<IAudience>;
listAudiences: (params?: {
cursor: string;
}) => Promise<IAudienceListResponse>;
listMembers: (id: string, params?: {
cursor: string;
}) => Promise<IAudienceMemberListResponse>;
put: (audience: Omit<IAudience, "created_at" | "updated_at">) => Promise<IAudience>;
}
export {};
2 changes: 2 additions & 0 deletions lib/audiences/types.js
@@ -0,0 +1,2 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
6 changes: 6 additions & 0 deletions lib/audit-events/index.d.ts
@@ -0,0 +1,6 @@
import { ICourierClientConfiguration } from "../types";
import { IAuditEvent, ICourierGetAuditEventParams, ICourierListAuditEventsParams, ICourierListAuditEventsResponse } from "./types";
export declare const auditEvents: (options: ICourierClientConfiguration) => {
get: (params: ICourierGetAuditEventParams) => Promise<IAuditEvent>;
list: (params: ICourierListAuditEventsParams) => Promise<ICourierListAuditEventsResponse>;
};
75 changes: 75 additions & 0 deletions lib/audit-events/index.js
@@ -0,0 +1,75 @@
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.auditEvents = void 0;
var list = function (options) {
return function (params) { return __awaiter(void 0, void 0, void 0, function () {
var res;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, options.httpClient.get("/audit-events", {
params: {
cursor: params.cursor
}
})];
case 1:
res = _a.sent();
return [2 /*return*/, res.data];
}
});
}); };
};
var get = function (options) {
return function (params) { return __awaiter(void 0, void 0, void 0, function () {
var res;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, options.httpClient.get("/audit-events/" + params.auditEventId)];
case 1:
res = _a.sent();
return [2 /*return*/, res.data];
}
});
}); };
};
exports.auditEvents = function (options) {
return {
get: get(options),
list: list(options)
};
};
27 changes: 27 additions & 0 deletions lib/audit-events/types.d.ts
@@ -0,0 +1,27 @@
export interface ICourierListAuditEventsParams {
cursor?: string;
}
export interface ICourierGetAuditEventParams {
auditEventId: string;
}
export interface ICourierListAuditEventsResponse {
paging: {
cursor?: string;
more: boolean;
};
results: IAuditEvent[];
}
export interface IAuditEvent {
actor?: {
id?: string;
email?: string;
};
target?: {
id?: string;
email?: string;
};
auditEventId: string;
source: string;
timestamp: string;
type: string;
}
2 changes: 2 additions & 0 deletions lib/audit-events/types.js
@@ -0,0 +1,2 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
3 changes: 3 additions & 0 deletions lib/automations/index.d.ts
@@ -0,0 +1,3 @@
import { ICourierClientConfiguration } from "../types";
import { ICourierClientAutomations } from "./types";
export declare const automations: (options: ICourierClientConfiguration) => ICourierClientAutomations;

0 comments on commit bb0c4f7

Please sign in to comment.