Socket
Socket
Sign inDemoInstall

@sajari/sdk-node

Package Overview
Dependencies
143
Maintainers
4
Versions
49
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.0-beta to 1.0.0-beta.1

dist/interaction.d.ts

22

dist/api.js

@@ -11,2 +11,13 @@ "use strict";

/**
* Custom formatter for call options.
* By default we hide the credentials from being logged to the console.
* @hidden
*/
debug_1.default.formatters.C = function callOptionsFormatter(options) {
if (process.env.DEBUG_SHOW_CREDS) {
return JSON.stringify(options);
}
return JSON.stringify({ deadline: options.deadline, credentials: "hidden" });
};
/**
* debug message logger

@@ -17,2 +28,3 @@ * @hidden

/**
* The default API endpoint
* @hidden

@@ -27,2 +39,7 @@ */

/**
* The deault grpc authority
* @hidden
*/
var AUTHORITY = "api.sajari.com";
/**
* APIClient wraps the grpc client, providing a single call method for

@@ -38,3 +55,3 @@ * creating an unary request.

this.client = new grpc_1.default.Client(this.endpoint, grpc_1.default.credentials.combineChannelCredentials(grpc_1.default.credentials.createSsl(), createCallCredentials(this.credentials.key, this.credentials.secret)), {
"grpc.default_authority": "api.sajari.com",
"grpc.default_authority": AUTHORITY,
"grpc.primary_user_agent": USER_AGENT

@@ -56,3 +73,3 @@ });

debug("grpc method: %j", path);
debug("call options: %j", callOptions);
debug("call options: %C", callOptions);
debug("request: %j", request);

@@ -103,3 +120,2 @@ _this.client.makeUnaryRequest(path, wrapEncoder(encoder), decoder, request, _this.metadata, {

metadata.add("authorization", "keysecret " + key + " " + secret);
debug("call credentials: %j", metadata);
callback(null, metadata);

@@ -106,0 +122,0 @@ });

@@ -5,2 +5,3 @@ import { FieldMutation } from "./engine/fieldMutation";

import { Record } from "./engine/record";
import { Interaction } from "./interaction";
import { Pipeline } from "./pipeline";

@@ -24,2 +25,3 @@ import { Schema } from "./schema";

schema(): Schema;
interaction(): Interaction;
}

@@ -43,2 +43,3 @@ "use strict";

var parse_1 = require("./engine/parse");
var interaction_1 = require("./interaction");
var pipeline_1 = require("./pipeline");

@@ -133,4 +134,7 @@ var schema_1 = require("./schema");

};
Client.prototype.interaction = function () {
return new interaction_1.Interaction(this.client);
};
return Client;
}());
exports.Client = Client;

14

dist/engine/fieldMutation.d.ts

@@ -23,11 +23,13 @@ import { sajari } from "../../generated/proto";

export declare function incrementField(field: string, value: string | string[] | null): FieldMutation;
export declare namespace FieldMutation {
/**
* toProto turns a FieldMutation into a
* sajari.engine.store.record.MutateRequest.RecordMutation.FieldMutation
* @hidden
*/
function toProto(fm: FieldMutation): sajari.engine.store.record.MutateRequest.RecordMutation.FieldMutation;
}
/**
* createFieldMutation turns a FieldMutation into a
* sajari.engine.store.record.MutateRequest.RecordMutation.FieldMutation
* @hidden
*/
export declare function createFieldMutation(fm: FieldMutation): sajari.engine.store.record.MutateRequest.RecordMutation.FieldMutation;
/**
* @hidden
*/
export declare function createMutationRequest(recordMutations: RecordMutation[]): sajari.engine.store.record.MutateRequest;

@@ -40,37 +40,40 @@ "use strict";

exports.incrementField = incrementField;
/**
* createFieldMutation turns a FieldMutation into a
* sajari.engine.store.record.MutateRequest.RecordMutation.FieldMutation
* @hidden
*/
function createFieldMutation(fm) {
var proto = {
field: fm.field,
mutation: fm.mutation
};
switch (fm.mutation) {
case "set":
if (fm.set === undefined) {
throw new Error("sajari: set mutation created, but there is no value for set");
}
proto.set = utils_1.Value.toProto(fm.set);
break;
case "increment":
if (fm.increment === undefined) {
throw new Error("sajari: increment mutation created, but there is no value for increment");
}
proto.increment = utils_1.Value.toProto(fm.increment);
break;
case "append":
if (fm.append === undefined) {
throw new Error("sajari: append mutation created, but there is no value for append");
}
proto.append = utils_1.Value.toProto(fm.append);
break;
default:
throw new Error("sajari: invalid mutation type: " + fm.mutation);
var FieldMutation;
(function (FieldMutation) {
/**
* toProto turns a FieldMutation into a
* sajari.engine.store.record.MutateRequest.RecordMutation.FieldMutation
* @hidden
*/
function toProto(fm) {
var proto = {
field: fm.field,
mutation: fm.mutation
};
switch (fm.mutation) {
case "set":
if (fm.set === undefined) {
throw new Error("sajari: set mutation created, but there is no value for set");
}
proto.set = utils_1.Value.toProto(fm.set);
break;
case "increment":
if (fm.increment === undefined) {
throw new Error("sajari: increment mutation created, but there is no value for increment");
}
proto.increment = utils_1.Value.toProto(fm.increment);
break;
case "append":
if (fm.append === undefined) {
throw new Error("sajari: append mutation created, but there is no value for append");
}
proto.append = utils_1.Value.toProto(fm.append);
break;
default:
throw new Error("sajari: invalid mutation type: " + fm.mutation);
}
return proto_1.sajari.engine.store.record.MutateRequest.RecordMutation.FieldMutation.create(proto);
}
return proto_1.sajari.engine.store.record.MutateRequest.RecordMutation.FieldMutation.create(proto);
}
exports.createFieldMutation = createFieldMutation;
FieldMutation.toProto = toProto;
})(FieldMutation = exports.FieldMutation || (exports.FieldMutation = {}));
/**

@@ -84,3 +87,3 @@ * @hidden

key: key_1.Key.toProto(recordMutation.key),
fieldMutations: recordMutation.mutations.map(createFieldMutation)
fieldMutations: recordMutation.mutations.map(FieldMutation.toProto)
});

@@ -87,0 +90,0 @@ })

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var fieldMutation_1 = require("./fieldMutation");
exports.FieldMutation = fieldMutation_1.FieldMutation;
var record_1 = require("./record");

@@ -7,3 +9,3 @@ exports.Record = record_1.Record;

exports.Key = key_1.Key;
var fieldMutation_1 = require("./fieldMutation");
exports.default = { setField: fieldMutation_1.setField, appendField: fieldMutation_1.appendField, incrementField: fieldMutation_1.incrementField };
var fieldMutation_2 = require("./fieldMutation");
exports.default = { setField: fieldMutation_2.setField, appendField: fieldMutation_2.appendField, incrementField: fieldMutation_2.incrementField };

@@ -12,8 +12,6 @@ "use strict";

var errors = response.status.map(utils_1.errorFromStatus);
return records.map(function (record, idx) {
return {
record: record,
error: errors[idx]
};
});
return records.map(function (record, idx) { return ({
record: record,
error: errors[idx]
}); });
}

@@ -27,9 +25,7 @@ exports.parseRecordResponse = parseRecordResponse;

var errors = response.status.map(utils_1.errorFromStatus);
return keys.map(function (key, idx) {
return {
key: key,
error: errors[idx]
};
});
return keys.map(function (key, idx) { return ({
key: key,
error: errors[idx]
}); });
}
exports.parseKeyResponse = parseKeyResponse;

@@ -18,3 +18,4 @@ "use strict";

exports.records = engine_1.default;
exports.FieldMutation = engine_1.FieldMutation;
exports.Record = engine_1.Record;
exports.Key = engine_1.Key;
import { sajari } from "../../generated/proto";
import { Key } from "../engine/key";
import { Record } from "../engine/record";
import { PipelineDefinition } from "./pipeline";
/**
* @hidden
*/
export declare const createAddRequest: (pipeline: {
name: string;
}, values: {
export declare const createAddRequest: (pipeline: PipelineDefinition, values: {
[k: string]: string;

@@ -11,0 +10,0 @@ }, records: Record[]) => sajari.api.pipeline.v1.AddRequest;

@@ -67,8 +67,6 @@ "use strict";

errors = res.status.map(utils_1.errorFromStatus);
return [2 /*return*/, keys.map(function (key, idx) {
return {
key: key,
error: errors[idx]
};
})];
return [2 /*return*/, keys.map(function (key, idx) { return ({
key: key,
error: errors[idx]
}); })];
});

@@ -75,0 +73,0 @@ });

@@ -1,77 +0,1 @@

import { APIClient, CallOptions } from "../api";
import { Key } from "../engine/key";
import { Record } from "../engine/record";
import { AddResponse } from "./add";
import { KeyRecord, ReplaceResponse } from "./replace";
import { SearchResponse } from "./search";
import { Tracking } from "./session";
/**
* Pipeline is a handler for a named pipeline.
*/
export interface Pipeline {
/**
* search runs a search query defined by a pipline with the given values and
* tracking configuration. Returns the query results and returned values
* (which could have been modified in the pipeline).
*/
search(values: {
[k: string]: string;
}, tracking: Tracking, options?: CallOptions): Promise<SearchResponse>;
/**
* Add a record to a collection using a pipeline, returning the unique key
* which can be used to retrieve the respective record.
*/
add(values: {
[k: string]: string;
}, record: Record, options?: CallOptions): Promise<Key>;
/**
* AddMulti adds multiple records to a collection using a pipeline, returning
* a list of AddResponse objects which either contain the Key for the
* respective record, or an Error if the add fails.
*/
addMulti(values: {
[k: string]: string;
}, records: Record[], options?: CallOptions): Promise<AddResponse[]>;
/**
* Replace a record to a collection using a pipeline, returning the unique
* Key which can be used to retrieve the respective record.
*/
replace(values: {
[k: string]: string;
}, keyRecord: KeyRecord, options?: CallOptions): Promise<Key>;
/**
* ReplaceMulti replaces multiple records in a collection using a pipeline,
* returning a list of ReplaceResponse objects which either contain the Key
* for the new record created, and empty Key if the record already exists
* and was replaced, or an Error if the replace fails.
*/
replaceMulti(values: {
[k: string]: string;
}, keyRecords: KeyRecord[], options?: CallOptions): Promise<ReplaceResponse[]>;
}
/**
* PipelineImpl is the implementation of a Pipeline
* @hidden
*/
export declare class PipelineImpl implements Pipeline {
private pipeline;
private client;
constructor(pipeline: {
name: string;
}, client: APIClient);
search(values: {
[k: string]: string;
}, tracking: Tracking, options?: CallOptions): Promise<SearchResponse>;
add(values: {
[k: string]: string;
}, record: Record, options?: CallOptions): Promise<Key>;
addMulti(values: {
[k: string]: string;
}, records: Record[], options?: CallOptions): Promise<AddResponse[]>;
replace(values: {
[k: string]: string;
}, keyRecord: KeyRecord, options?: CallOptions): Promise<Key>;
replaceMulti(values: {
[k: string]: string;
}, keyRecords: KeyRecord[], options?: CallOptions): Promise<ReplaceResponse[]>;
}
export { Pipeline, PipelineDefinition, PipelineImpl } from "./pipeline";
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
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) : new P(function (resolve) { resolve(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 });
var proto_1 = require("../../generated/proto");
var add_1 = require("./add");
var replace_1 = require("./replace");
var search_1 = require("./search");
/**
* grpc method path for record ingestetion via a pipeline
* @hidden
*/
var PipelineAddMethod = "sajari.api.pipeline.v1.Store/Add";
/**
* grpc method path for replace
* @hidden
*/
var PipelineReplaceMethod = "sajari.api.pipeline.v1.Store/Replace";
/**
* grpc method path for querying records
* @hidden
*/
var PipelineSearchMethod = "sajari.api.pipeline.v1.Query/Search";
/**
* PipelineImpl is the implementation of a Pipeline
* @hidden
*/
var PipelineImpl = /** @class */ (function () {
function PipelineImpl(pipeline, client) {
this.pipeline = pipeline;
this.client = client;
}
PipelineImpl.prototype.search = function (values, tracking, options) {
return __awaiter(this, void 0, void 0, function () {
var request, response, results;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
request = search_1.createSearchRequest(this.pipeline, values, tracking);
return [4 /*yield*/, this.client.call(PipelineSearchMethod, request, proto_1.sajari.api.pipeline.v1.SearchRequest.encode, proto_1.sajari.api.pipeline.v1.SearchResponse.decode, options)];
case 1:
response = _a.sent();
results = search_1.parseSearchResponse(response);
return [2 /*return*/, { results: results, values: response.values }];
}
});
});
};
PipelineImpl.prototype.add = function (values, record, options) {
return __awaiter(this, void 0, void 0, function () {
var response, res;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this.addMulti(values, [record], options)];
case 1:
response = _a.sent();
res = response[0];
if (res.error) {
throw res.error;
}
return [2 /*return*/, res.key];
}
});
});
};
PipelineImpl.prototype.addMulti = function (values, records, options) {
return __awaiter(this, void 0, void 0, function () {
var request, response;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
request = add_1.createAddRequest(this.pipeline, values, records);
return [4 /*yield*/, this.client.call(PipelineAddMethod, request, proto_1.sajari.api.pipeline.v1.AddRequest.encode, proto_1.sajari.api.pipeline.v1.AddResponse.decode, options)];
case 1:
response = _a.sent();
if (response.response == null) {
throw new Error("sajari: empty response");
}
return [2 /*return*/, add_1.parseAddResponse(response.response)];
}
});
});
};
PipelineImpl.prototype.replace = function (values, keyRecord, options) {
return __awaiter(this, void 0, void 0, function () {
var response, res;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this.replaceMulti(values, [keyRecord], options)];
case 1:
response = _a.sent();
res = response[0];
if (res.error) {
throw res.error;
}
return [2 /*return*/, res.key];
}
});
});
};
PipelineImpl.prototype.replaceMulti = function (values, keyRecords, options) {
return __awaiter(this, void 0, void 0, function () {
var request, response;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
request = replace_1.createReplaceRequest(this.pipeline, values, keyRecords);
return [4 /*yield*/, this.client.call(PipelineReplaceMethod, request, proto_1.sajari.api.pipeline.v1.ReplaceRequest.encode, proto_1.sajari.api.pipeline.v1.ReplaceResponse.decode, options)];
case 1:
response = _a.sent();
if (response.response == null) {
throw new Error("sajari: empty response");
}
return [2 /*return*/, replace_1.parseReplaceResponse(response.response)];
}
});
});
};
return PipelineImpl;
}());
exports.PipelineImpl = PipelineImpl;
var pipeline_1 = require("./pipeline");
exports.PipelineImpl = pipeline_1.PipelineImpl;
import { sajari } from "../../generated/proto";
import { Key } from "../engine/key";
import { Record } from "../engine/record";
import { PipelineDefinition } from "./pipeline";
/**

@@ -14,5 +15,3 @@ * KeyRecord is a key-record pair.

*/
export declare function createReplaceRequest(pipeline: {
name: string;
}, values: {
export declare function createReplaceRequest(pipeline: PipelineDefinition, values: {
[k: string]: string;

@@ -19,0 +18,0 @@ }, keyRecords: KeyRecord[]): sajari.api.pipeline.v1.ReplaceRequest;

import { sajari } from "../../generated/proto";
import { PipelineDefinition } from "./pipeline";
import { Token, Tracking } from "./session";

@@ -27,5 +28,3 @@ export interface Result {

*/
export declare const createSearchRequest: (pipeline: {
name: string;
}, values: {
export declare const createSearchRequest: (pipeline: PipelineDefinition, values: {
[k: string]: string;

@@ -32,0 +31,0 @@ }, tracking: Tracking) => sajari.api.pipeline.v1.SearchRequest;

@@ -56,3 +56,3 @@ "use strict";

if (t.posNeg.pos === "" ||
t.posNeg.pos === "" ||
t.posNeg.neg === "" ||
(t.posNeg.pos == null || t.posNeg.neg == null)) {

@@ -59,0 +59,0 @@ throw new Error("sajari: invalid posNeg token");

@@ -42,2 +42,17 @@ "use strict";

var utils_2 = require("./utils");
/**
* grpc method endpoint for getting the current schema fields
* @hidden
*/
var GetFieldsMethod = "sajari.engine.schema.Schema/GetFields";
/**
* grpc method endpoint for adding fields to the schema
* @hidden
*/
var AddFieldsMethod = "sajari.engine.schema.Schema/AddFields";
/**
* grpc method endpoint for mutating a schema field
* @hidden
*/
var MutateFieldMethod = "sajari.engine.schema.Schema/MutateField";
var Schema = /** @class */ (function () {

@@ -55,3 +70,3 @@ function Schema(client) {

request = new proto_1.sajari.rpc.Empty();
return [4 /*yield*/, this.client.call("sajari.engine.schema.Schema/GetFields", request, proto_1.sajari.rpc.Empty.encode, proto_1.sajari.engine.schema.Fields.decode, options)];
return [4 /*yield*/, this.client.call(GetFieldsMethod, request, proto_1.sajari.rpc.Empty.encode, proto_1.sajari.engine.schema.Fields.decode, options)];
case 1:

@@ -72,3 +87,3 @@ response = _a.sent();

request = utils_2.createAddRequest(fields);
return [4 /*yield*/, this.client.call("sajari.engine.schema.Schema/AddFields", request, proto_1.sajari.engine.schema.Fields.encode, proto_1.sajari.engine.schema.Response.decode, options)];
return [4 /*yield*/, this.client.call(AddFieldsMethod, request, proto_1.sajari.engine.schema.Fields.encode, proto_1.sajari.engine.schema.Response.decode, options)];
case 1:

@@ -95,3 +110,3 @@ response = _a.sent();

request = utils_2.createMutateFieldRequest(name, mutations);
return [4 /*yield*/, this.client.call("sajari.engine.schema.Schema/MutateField", request, proto_1.sajari.engine.schema.MutateFieldRequest.encode, proto_1.sajari.engine.schema.Response.decode, options)];
return [4 /*yield*/, this.client.call(MutateFieldMethod, request, proto_1.sajari.engine.schema.MutateFieldRequest.encode, proto_1.sajari.engine.schema.Response.decode, options)];
case 1:

@@ -98,0 +113,0 @@ response = _a.sent();

@@ -10,12 +10,2 @@ import { sajari } from "../../generated/proto";

mode: FieldMode;
/**
* deprecated
* @hidden
*/
required: boolean;
/**
* deprecated
* @hidden
*/
unique: boolean;
repeated: boolean;

@@ -85,12 +75,2 @@ indexed?: boolean;

mode?: FieldMode;
/**
* deprecated
* @hidden
*/
required?: boolean;
/**
* deprecated
* @hidden
*/
unique?: boolean;
}

@@ -101,1 +81,9 @@ /**

export declare function field(type: Type, name: string, options?: FieldOptions): Field;
export declare const fields: {
string(name: string, options: FieldOptions): Field;
integer(name: string, options: FieldOptions): Field;
float(name: string, options: FieldOptions): Field;
double(name: string, options: FieldOptions): Field;
boolean(name: string, options: FieldOptions): Field;
timestamp(name: string, options: FieldOptions): Field;
};

@@ -34,4 +34,2 @@ "use strict";

mode: FieldMode.fromProto(engineField.mode),
required: engineField.required,
unique: engineField.unique,
repeated: engineField.repeated,

@@ -150,5 +148,3 @@ indexed: engineField.indexed

repeated: false,
mode: FieldMode.Nullable,
required: false,
unique: false
mode: FieldMode.Nullable
};

@@ -160,11 +156,2 @@ /**

options = deepmerge_1.default(defaultFieldOptions, options || {});
switch (options.mode) {
case FieldMode.Required:
options.required = true;
break;
case FieldMode.Unique:
options.unique = true;
default:
break;
}
// XXX: We are type casting bellow due to a limitation in the types

@@ -177,7 +164,25 @@ // produced by the merge function above.

repeated: options.repeated,
mode: options.mode,
unique: options.unique,
required: options.required
mode: options.mode
};
}
exports.field = field;
exports.fields = {
string: function (name, options) {
return field(Type.String, name, options);
},
integer: function (name, options) {
return field(Type.Integer, name, options);
},
float: function (name, options) {
return field(Type.Float, name, options);
},
double: function (name, options) {
return field(Type.Double, name, options);
},
boolean: function (name, options) {
return field(Type.Boolean, name, options);
},
timestamp: function (name, options) {
return field(Type.Timestamp, name, options);
}
};

@@ -1,2 +0,1 @@

import { Field, FieldOptions, Type } from "./field";
export { Mutation, NameMutation, DescriptionMutation, TypeMutation, RepeatedMutation } from "./mutation";

@@ -7,8 +6,8 @@ export { FieldMode } from "./field";

field: {
string(name: string, options: FieldOptions): Field;
integer(name: string, options: FieldOptions): Field;
float(name: string, options: FieldOptions): Field;
double(name: string, options: FieldOptions): Field;
boolean(name: string, options: FieldOptions): Field;
timestamp(name: string, options: FieldOptions): Field;
string(name: string, options: import("./field").FieldOptions): import("./field").Field;
integer(name: string, options: import("./field").FieldOptions): import("./field").Field;
float(name: string, options: import("./field").FieldOptions): import("./field").Field;
double(name: string, options: import("./field").FieldOptions): import("./field").Field;
boolean(name: string, options: import("./field").FieldOptions): import("./field").Field;
timestamp(name: string, options: import("./field").FieldOptions): import("./field").Field;
};

@@ -15,0 +14,0 @@ mutation: {

@@ -12,23 +12,4 @@ "use strict";

exports.default = {
field: {
string: function (name, options) {
return field_1.field(field_1.Type.String, name, options);
},
integer: function (name, options) {
return field_1.field(field_1.Type.Integer, name, options);
},
float: function (name, options) {
return field_1.field(field_1.Type.Float, name, options);
},
double: function (name, options) {
return field_1.field(field_1.Type.Double, name, options);
},
boolean: function (name, options) {
return field_1.field(field_1.Type.Boolean, name, options);
},
timestamp: function (name, options) {
return field_1.field(field_1.Type.Timestamp, name, options);
}
},
field: field_1.fields,
mutation: mutation_1.mutation
};

@@ -31,5 +31,2 @@ import { sajari } from "../generated/proto";

}
/**
* @hidden
*/
export declare class Errors extends Array<Error> {

@@ -36,0 +33,0 @@ constructor(errors: {

@@ -134,5 +134,2 @@ "use strict";

exports.MultiError = MultiError;
/**
* @hidden
*/
var Errors = /** @class */ (function (_super) {

@@ -139,0 +136,0 @@ __extends(Errors, _super);

{
"name": "@sajari/sdk-node",
"version": "1.0.0-beta",
"version": "1.0.0-beta.1",
"main": "dist/index.js",

@@ -34,3 +34,3 @@ "types": "dist/index.d.ts",

"deepmerge": "^2.2.1",
"grpc": "^1.15.1",
"grpc": "1.15.1",
"protobufjs": "^6.8.8"

@@ -40,3 +40,3 @@ },

"@types/debug": "0.0.31",
"@types/jest": "^23.3.5",
"@types/jest": "^23.3.9",
"globby": "^8.0.1",

@@ -47,9 +47,9 @@ "grpc-tools": "^1.6.6",

"npm-run-all": "^4.1.3",
"prettier": "^1.14.3",
"prettier": "^1.15.2",
"ts-jest": "^23.10.4",
"tslint": "^5.11.0",
"tslint-config-prettier": "^1.15.0",
"tslint-config-prettier": "^1.16.0",
"typedoc": "^0.13.0",
"typescript": "^3.1.3"
"typescript": "^3.1.6"
}
}

@@ -29,6 +29,6 @@ # @sajari/sdk-node

```js
const { DefaultClient, FieldMode } = require("@sajari/sdk-node");
const { Client, FieldMode, schema } = require("@sajari/sdk-node");
// create client
const client = new DefaultClient("<project>", "<collection>", {
const client = new Client("<project>", "<collection>", {
key: "<key from console>",

@@ -38,7 +38,4 @@ secret: "<secret from console>"

// get schema client
const schema = client.schema()
const fields = [
schema.boolean("my-boolean-field", {
schema.field.boolean("my-boolean-field", {
// Set this field to be required.

@@ -49,6 +46,6 @@ // FieldMode options are defined here,

}),
schema.string("text")
schema.field.string("text")
]
schema.add(...fields).catch(error => {/* handle error ... */})
client.schema().add(...fields).catch(error => {/* handle error ... */})
```

@@ -58,6 +55,6 @@

```js
const { DefaultClient } = require("@sajari/sdk-node");
const { Client } = require("@sajari/sdk-node");
// create client
const client = new DefaultClient("<project>", "<collection>", {
const client = new Client("<project>", "<collection>", {
key: "<key from console>",

@@ -82,5 +79,5 @@ secret: "<secret from console>"

```js
const { DefaultClient, DefaultSession, TrackingType } = require("@sajari/sdk-node");
const { Client, DefaultSession, TrackingType } = require("@sajari/sdk-node");
const client = new DefaultClient("<project>", "<collection>", {
const client = new Client("<project>", "<collection>", {
key: "<key from console>",

@@ -87,0 +84,0 @@ secret: "<secret from console>"

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc