repo_name
string
dataset
string
owner
string
lang
string
func_name
string
code
string
docstring
string
url
string
sha
string
code-snippet-editor-plugin
github_2023
figma
typescript
downcase
function downcase(name: string) { return `${name.charAt(0).toLowerCase()}${name.slice(1)}`; }
/** * Lowercase the first character in a string * @param name the string to downcase * @returns downcased string */
https://github.com/figma/code-snippet-editor-plugin/blob/ece47d8ccfa0f6ab6704ceab2cae11b8dc7d7c09/src/params.ts#L383-L385
ece47d8ccfa0f6ab6704ceab2cae11b8dc7d7c09
code-snippet-editor-plugin
github_2023
figma
typescript
numericGuard
function numericGuard(name = "") { if (name.charAt(0).match(/\d/)) { name = `N${name}`; } return name; }
/** * Ensure a string does not start with a number * @param name the string to guard that can start with a number * @returns string that starts with a letter */
https://github.com/figma/code-snippet-editor-plugin/blob/ece47d8ccfa0f6ab6704ceab2cae11b8dc7d7c09/src/params.ts#L392-L397
ece47d8ccfa0f6ab6704ceab2cae11b8dc7d7c09
code-snippet-editor-plugin
github_2023
figma
typescript
capitalizedNameFromName
function capitalizedNameFromName(name = "") { name = numericGuard(name); return name .split(/[^a-zA-Z\d]+/g) .map(capitalize) .join(""); }
/** * Transform a string into a proper capitalized string that cannot start with a number * @param name the string to capitalize * @returns capitalized name */
https://github.com/figma/code-snippet-editor-plugin/blob/ece47d8ccfa0f6ab6704ceab2cae11b8dc7d7c09/src/params.ts#L404-L410
ece47d8ccfa0f6ab6704ceab2cae11b8dc7d7c09
code-snippet-editor-plugin
github_2023
figma
typescript
sanitizePropertyName
function sanitizePropertyName(name: string) { name = name.replace(/#[^#]+$/g, ""); return downcase(capitalizedNameFromName(name).replace(/^\d+/g, "")); }
/** * A clean property name from a potentially gross string * @param name the name to sanitize * @returns a sanitized string */
https://github.com/figma/code-snippet-editor-plugin/blob/ece47d8ccfa0f6ab6704ceab2cae11b8dc7d7c09/src/params.ts#L417-L420
ece47d8ccfa0f6ab6704ceab2cae11b8dc7d7c09
code-snippet-editor-plugin
github_2023
figma
typescript
getComponentNodeFromNode
function getComponentNodeFromNode( node: BaseNode ): ComponentNode | ComponentSetNode | null { const { type, parent } = node; const parentType = parent ? parent.type : ""; const isVariant = parentType === "COMPONENT_SET"; if (type === "COMPONENT_SET" || (type === "COMPONENT" && !isVariant)) { return node;...
/** * Get the appropriate topmost component node for a given node * @param node node to find the right component node for * @returns a component or component set node if it exists, otherwise null */
https://github.com/figma/code-snippet-editor-plugin/blob/ece47d8ccfa0f6ab6704ceab2cae11b8dc7d7c09/src/params.ts#L427-L450
ece47d8ccfa0f6ab6704ceab2cae11b8dc7d7c09
code-snippet-editor-plugin
github_2023
figma
typescript
safeString
function safeString(string = "") { string = string.replace(/([^a-zA-Z0-9-_// ])/g, ""); if (!string.match(/^[A-Z0-9_]+$/)) { string = string.replace(/([A-Z])/g, " $1"); } return string .replace(/([a-z])([0-9])/g, "$1 $2") .replace(/([-_/])/g, " ") .replace(/ +/g, " ") .trim() .toLowerCa...
/** * Turn any string into a safe, hyphenated lowercase string * @param string the string to transform * @returns the safe string */
https://github.com/figma/code-snippet-editor-plugin/blob/ece47d8ccfa0f6ab6704ceab2cae11b8dc7d7c09/src/params.ts#L457-L470
ece47d8ccfa0f6ab6704ceab2cae11b8dc7d7c09
code-snippet-editor-plugin
github_2023
figma
typescript
valueIsCodegenLanguage
function valueIsCodegenLanguage( value: any ): value is CodegenResult["language"] { return CODEGEN_LANGUAGES.includes(value as CodegenResult["language"]); }
/** * Type safety function to return if the argument "value" is a valid CodegenResult["language"] * @param value the value to validate * @returns whether or not the value is a CodegenResult["language"] */
https://github.com/figma/code-snippet-editor-plugin/blob/ece47d8ccfa0f6ab6704ceab2cae11b8dc7d7c09/src/pluginData.ts#L64-L68
ece47d8ccfa0f6ab6704ceab2cae11b8dc7d7c09
code-snippet-editor-plugin
github_2023
figma
typescript
objectIsCodegenResult
function objectIsCodegenResult(object: Object): object is CodegenResult { if (typeof object !== "object") return false; if (Object.keys(object).length !== 3) return false; if (!("title" in object && "code" in object && "language" in object)) return false; if (typeof object.title !== "string" || typeof objec...
/** * Type safety function that validates if an object is a CodegenResult object * @param object the object to validate * @returns whether or not the object is a CodegenResult */
https://github.com/figma/code-snippet-editor-plugin/blob/ece47d8ccfa0f6ab6704ceab2cae11b8dc7d7c09/src/pluginData.ts#L75-L83
ece47d8ccfa0f6ab6704ceab2cae11b8dc7d7c09
code-snippet-editor-plugin
github_2023
figma
typescript
arrayContainsCodegenResults
function arrayContainsCodegenResults(array: any): array is CodegenResult[] { let valid = true; if (Array.isArray(array)) { array.forEach((object) => { if (!objectIsCodegenResult(object)) { valid = false; } }); } else { valid = false; } return valid; }
/** * Type safety function that validates if an array is an array of CodeResult objects * @param array the array to validate * @returns whether or not the array is a CodegenResult[] */
https://github.com/figma/code-snippet-editor-plugin/blob/ece47d8ccfa0f6ab6704ceab2cae11b8dc7d7c09/src/pluginData.ts#L90-L102
ece47d8ccfa0f6ab6704ceab2cae11b8dc7d7c09
code-snippet-editor-plugin
github_2023
figma
typescript
pluginDataStringAsValidCodegenResults
function pluginDataStringAsValidCodegenResults( pluginDataString: string ): CodegenResult[] | null { if (!pluginDataString) return null; try { const parsed = JSON.parse(pluginDataString); return arrayContainsCodegenResults(parsed) ? parsed : null; } catch (e) { return null; } }
/** * Given a JSON string from pluginData, return a valid CodegenResult[] or null if string is invalid * @param pluginDataString the string that may or may not be a JSON-stringified CodegenResult[] * @returns CodegenResult[] or null */
https://github.com/figma/code-snippet-editor-plugin/blob/ece47d8ccfa0f6ab6704ceab2cae11b8dc7d7c09/src/pluginData.ts#L109-L119
ece47d8ccfa0f6ab6704ceab2cae11b8dc7d7c09
code-snippet-editor-plugin
github_2023
figma
typescript
unescapeBrackets
const unescapeBrackets = (line: string) => line.replace(/\\\{\{/g, "{{");
/** * Replacing escaped brackets with standard brackets. * Brackets only need to be escaped when used in a way that matches "{{...}}" * "\{{hi}}" becomes "{{hi}}" */
https://github.com/figma/code-snippet-editor-plugin/blob/ece47d8ccfa0f6ab6704ceab2cae11b8dc7d7c09/src/snippets.ts#L27-L27
ece47d8ccfa0f6ab6704ceab2cae11b8dc7d7c09
code-snippet-editor-plugin
github_2023
figma
typescript
snippetTemplatesForNode
async function snippetTemplatesForNode( snippetNode: BaseNode, seenSnippetTemplates: { [k: string]: number }, globalTemplates: CodeSnippetGlobalTemplates, parentCodegenResult?: CodegenResult ) { const codegenResults = getCodegenResultsFromPluginData(snippetNode); const matchingTemplates = (templates: Codege...
/** * Process snippets for any node. Called multiple times up the lineage for component and instance nodes. * Instances have the same pluginData as their mainComponent, unless they have overridden the pluginData. * This tracks these duplicate cases in seenSnippetTemplates and filters them out. * @param snippetNode ...
https://github.com/figma/code-snippet-editor-plugin/blob/ece47d8ccfa0f6ab6704ceab2cae11b8dc7d7c09/src/snippets.ts#L188-L237
ece47d8ccfa0f6ab6704ceab2cae11b8dc7d7c09
code-snippet-editor-plugin
github_2023
figma
typescript
findChildrenSnippets
async function findChildrenSnippets( childrenSnippetParams: CodeSnippetParamsMap[], indent: string, recursionIndex: number, globalTemplates: CodeSnippetGlobalTemplates ): Promise<string> { const string: string[] = []; for (let childSnippetParams of childrenSnippetParams) { const snippetId = Object.keys(...
/** * * @param childrenSnippetParams an array of children snippet params map * @param indent indentation string * @param recursionIndex tracking recursion to prevent infinite loops * @param globalTemplates the CodeSnippetGlobalTemplates to reference * @returns a Promise that resolves a string of all children snip...
https://github.com/figma/code-snippet-editor-plugin/blob/ece47d8ccfa0f6ab6704ceab2cae11b8dc7d7c09/src/snippets.ts#L431-L454
ece47d8ccfa0f6ab6704ceab2cae11b8dc7d7c09
code-snippet-editor-plugin
github_2023
figma
typescript
lineConditionalMatch
function lineConditionalMatch( line: string, params: CodeSnippetParams, templateChildren?: CodeSnippetParamsMap[] ): [RegExpMatchArray[], boolean] { /** * Line conditional statement matches. * {{?something=value}} * {{!something=value}} * {{?something}} * {{?something=value|something=other}} *...
/** * Handling any conditional statements and on a line of a template and determining whether or not to render. * No conditional statements is valid, and the line should render. * This only checks for conditional statements, symbols can still invalidate the line if the params dont exist. * @param line the line of ...
https://github.com/figma/code-snippet-editor-plugin/blob/ece47d8ccfa0f6ab6704ceab2cae11b8dc7d7c09/src/snippets.ts#L464-L529
ece47d8ccfa0f6ab6704ceab2cae11b8dc7d7c09
code-snippet-editor-plugin
github_2023
figma
typescript
templatesIsCodeSnippetGlobalTemplates
function templatesIsCodeSnippetGlobalTemplates( templates: CodeSnippetGlobalTemplates | any ): templates is CodeSnippetGlobalTemplates { if (typeof templates === "object" && !Array.isArray(templates)) { const keys = Object.keys(templates); if (keys.find((k) => k !== "components" && k !== "types")) { r...
/** * Type safety function to indicate if item in clientStorage is CodeSnippetGlobalTemplates or not. * @param templates item in question * @returns whether or not the argument is CodeSnippetGlobalTemplates */
https://github.com/figma/code-snippet-editor-plugin/blob/ece47d8ccfa0f6ab6704ceab2cae11b8dc7d7c09/src/templates.ts#L8-L19
ece47d8ccfa0f6ab6704ceab2cae11b8dc7d7c09
confluent-kafka-javascript
github_2023
confluentinc
typescript
token_refresh
async function token_refresh() { try { // Make a POST request to get the access token const response = await axios.post(issuerEndpointUrl, new URLSearchParams({ grant_type: 'client_credentials', client_id: oauthClientId, client_secret: oauthClientSecret, scope: scope }), { he...
// Only showing the producer, will be the same implementation for the consumer
https://github.com/confluentinc/confluent-kafka-javascript/blob/26710e6ec5c8ff8415f2d01dddabb811327c6cde/schemaregistry-examples/src/kafka-oauth.ts#L17-L48
26710e6ec5c8ff8415f2d01dddabb811327c6cde
confluent-kafka-javascript
github_2023
confluentinc
typescript
RestError.constructor
constructor(message: string, status: number, errorCode: number) { super(message + "; Error code: " + errorCode); this.status = status; this.errorCode = errorCode; }
/** * Creates a new REST error. * @param message - The error message. * @param status - The HTTP status code. * @param errorCode - The error code. */
https://github.com/confluentinc/confluent-kafka-javascript/blob/26710e6ec5c8ff8415f2d01dddabb811327c6cde/schemaregistry/rest-error.ts#L14-L18
26710e6ec5c8ff8415f2d01dddabb811327c6cde
confluent-kafka-javascript
github_2023
confluentinc
typescript
SchemaRegistryClient.constructor
constructor(config: ClientConfig) { this.clientConfig = config const cacheOptions = { max: config.cacheCapacity !== undefined ? config.cacheCapacity : 1000, ...(config.cacheLatestTtlSecs !== undefined && { ttl: config.cacheLatestTtlSecs * 1000 }) }; this.restService = new RestService(config...
/** * Create a new Schema Registry client. * @param config - The client configuration. */
https://github.com/confluentinc/confluent-kafka-javascript/blob/26710e6ec5c8ff8415f2d01dddabb811327c6cde/schemaregistry/schemaregistry-client.ts#L197-L222
26710e6ec5c8ff8415f2d01dddabb811327c6cde
confluent-kafka-javascript
github_2023
confluentinc
typescript
SchemaRegistryClient.register
async register(subject: string, schema: SchemaInfo, normalize: boolean = false): Promise<number> { const metadataResult = await this.registerFullResponse(subject, schema, normalize); return metadataResult.id; }
/** * Register a schema with the Schema Registry and return the schema ID. * @param subject - The subject under which to register the schema. * @param schema - The schema to register. * @param normalize - Whether to normalize the schema before registering. */
https://github.com/confluentinc/confluent-kafka-javascript/blob/26710e6ec5c8ff8415f2d01dddabb811327c6cde/schemaregistry/schemaregistry-client.ts#L242-L246
26710e6ec5c8ff8415f2d01dddabb811327c6cde
confluent-kafka-javascript
github_2023
confluentinc
typescript
SchemaRegistryClient.registerFullResponse
async registerFullResponse(subject: string, schema: SchemaInfo, normalize: boolean = false): Promise<SchemaMetadata> { const cacheKey = stringify({ subject, schema: minimize(schema) }); return await this.infoToSchemaMutex.runExclusive(async () => { const cachedSchemaMetadata: SchemaMetadata | undefined =...
/** * Register a schema with the Schema Registry and return the full response. * @param subject - The subject under which to register the schema. * @param schema - The schema to register. * @param normalize - Whether to normalize the schema before registering. */
https://github.com/confluentinc/confluent-kafka-javascript/blob/26710e6ec5c8ff8415f2d01dddabb811327c6cde/schemaregistry/schemaregistry-client.ts#L254-L273
26710e6ec5c8ff8415f2d01dddabb811327c6cde
confluent-kafka-javascript
github_2023
confluentinc
typescript
SchemaRegistryClient.getBySubjectAndId
async getBySubjectAndId(subject: string, id: number, format?: string): Promise<SchemaInfo> { const cacheKey = stringify({ subject, id }); return await this.idToSchemaInfoMutex.runExclusive(async () => { const cachedSchema: SchemaInfo | undefined = this.idToSchemaInfoCache.get(cacheKey); if (cachedSc...
/** * Get a schema by subject and ID. * @param subject - The subject under which the schema is registered. * @param id - The schema ID. * @param format - The format of the schema. */
https://github.com/confluentinc/confluent-kafka-javascript/blob/26710e6ec5c8ff8415f2d01dddabb811327c6cde/schemaregistry/schemaregistry-client.ts#L281-L300
26710e6ec5c8ff8415f2d01dddabb811327c6cde
confluent-kafka-javascript
github_2023
confluentinc
typescript
SchemaRegistryClient.getId
async getId(subject: string, schema: SchemaInfo, normalize: boolean = false): Promise<number> { const cacheKey = stringify({ subject, schema: minimize(schema) }); return await this.schemaToIdMutex.runExclusive(async () => { const cachedId: number | undefined = this.schemaToIdCache.get(cacheKey); if...
/** * Get the ID for a schema. * @param subject - The subject under which the schema is registered. * @param schema - The schema whose ID to get. * @param normalize - Whether to normalize the schema before getting the ID. */
https://github.com/confluentinc/confluent-kafka-javascript/blob/26710e6ec5c8ff8415f2d01dddabb811327c6cde/schemaregistry/schemaregistry-client.ts#L308-L327
26710e6ec5c8ff8415f2d01dddabb811327c6cde
confluent-kafka-javascript
github_2023
confluentinc
typescript
SchemaRegistryClient.getLatestSchemaMetadata
async getLatestSchemaMetadata(subject: string, format?: string): Promise<SchemaMetadata> { return await this.latestToSchemaMutex.runExclusive(async () => { const cachedSchema: SchemaMetadata | undefined = this.latestToSchemaCache.get(subject); if (cachedSchema) { return cachedSchema; } ...
/** * Get the latest schema metadata for a subject. * @param subject - The subject for which to get the latest schema metadata. * @param format - The format of the schema. */
https://github.com/confluentinc/confluent-kafka-javascript/blob/26710e6ec5c8ff8415f2d01dddabb811327c6cde/schemaregistry/schemaregistry-client.ts#L334-L352
26710e6ec5c8ff8415f2d01dddabb811327c6cde
confluent-kafka-javascript
github_2023
confluentinc
typescript
SchemaRegistryClient.getSchemaMetadata
async getSchemaMetadata(subject: string, version: number, deleted: boolean = false, format?: string): Promise<SchemaMetadata> { const cacheKey = stringify({ subject, version, deleted }); return await this.versionToSchemaMutex.runExclusive(async () => { const cachedSchemaMetadata: SchemaMetadata | undefin...
/** * Get the schema metadata for a subject and version. * @param subject - The subject for which to get the schema metadata. * @param version - The version of the schema. * @param deleted - Whether to include deleted schemas. * @param format - The format of the schema. */
https://github.com/confluentinc/confluent-kafka-javascript/blob/26710e6ec5c8ff8415f2d01dddabb811327c6cde/schemaregistry/schemaregistry-client.ts#L361-L381
26710e6ec5c8ff8415f2d01dddabb811327c6cde
confluent-kafka-javascript
github_2023
confluentinc
typescript
SchemaRegistryClient.getLatestWithMetadata
async getLatestWithMetadata(subject: string, metadata: { [key: string]: string }, deleted: boolean = false, format?: string): Promise<SchemaMetadata> { const cacheKey = stringify({ subject, metadata, deleted }); return await this.metadataToSchemaMutex.runExclusive(async () => { ...
/** * Get the latest schema metadata for a subject with the given metadata. * @param subject - The subject for which to get the latest schema metadata. * @param metadata - The metadata to match. * @param deleted - Whether to include deleted schemas. * @param format - The format of the schema. */
https://github.com/confluentinc/confluent-kafka-javascript/blob/26710e6ec5c8ff8415f2d01dddabb811327c6cde/schemaregistry/schemaregistry-client.ts#L390-L419
26710e6ec5c8ff8415f2d01dddabb811327c6cde
confluent-kafka-javascript
github_2023
confluentinc
typescript
SchemaRegistryClient.getAllVersions
async getAllVersions(subject: string): Promise<number[]> { const response: AxiosResponse<number[]> = await this.restService.handleRequest( `/subjects/${subject}/versions`, 'GET' ); return response.data; }
/** * Get all versions of a schema for a subject. * @param subject - The subject for which to get all versions. */
https://github.com/confluentinc/confluent-kafka-javascript/blob/26710e6ec5c8ff8415f2d01dddabb811327c6cde/schemaregistry/schemaregistry-client.ts#L425-L431
26710e6ec5c8ff8415f2d01dddabb811327c6cde
confluent-kafka-javascript
github_2023
confluentinc
typescript
SchemaRegistryClient.getVersion
async getVersion(subject: string, schema: SchemaInfo, normalize: boolean = false, deleted: boolean = false): Promise<number> { const cacheKey = stringify({ subject, schema: minimize(schema), deleted }); return await this.schemaToVersionMutex.runExclusive(async () => { const cachedVersi...
/** * Get the version of a schema for a subject. * @param subject - The subject for which to get the version. * @param schema - The schema for which to get the version. * @param normalize - Whether to normalize the schema before getting the version. */
https://github.com/confluentinc/confluent-kafka-javascript/blob/26710e6ec5c8ff8415f2d01dddabb811327c6cde/schemaregistry/schemaregistry-client.ts#L439-L459
26710e6ec5c8ff8415f2d01dddabb811327c6cde
confluent-kafka-javascript
github_2023
confluentinc
typescript
SchemaRegistryClient.getAllSubjects
async getAllSubjects(): Promise<string[]> { const response: AxiosResponse<string[]> = await this.restService.handleRequest( `/subjects`, 'GET' ); return response.data; }
/** * Get all subjects in the Schema Registry. */
https://github.com/confluentinc/confluent-kafka-javascript/blob/26710e6ec5c8ff8415f2d01dddabb811327c6cde/schemaregistry/schemaregistry-client.ts#L464-L470
26710e6ec5c8ff8415f2d01dddabb811327c6cde
confluent-kafka-javascript
github_2023
confluentinc
typescript
SchemaRegistryClient.deleteSubject
async deleteSubject(subject: string, permanent: boolean = false): Promise<number[]> { await this.infoToSchemaMutex.runExclusive(async () => { this.infoToSchemaCache.forEach((_, key) => { const parsedKey = JSON.parse(key); if (parsedKey.subject === subject) { this.infoToSchemaCache.de...
/** * Delete a subject from the Schema Registry. * @param subject - The subject to delete. * @param permanent - Whether to permanently delete the subject. */
https://github.com/confluentinc/confluent-kafka-javascript/blob/26710e6ec5c8ff8415f2d01dddabb811327c6cde/schemaregistry/schemaregistry-client.ts#L477-L521
26710e6ec5c8ff8415f2d01dddabb811327c6cde
confluent-kafka-javascript
github_2023
confluentinc
typescript
SchemaRegistryClient.deleteSubjectVersion
async deleteSubjectVersion(subject: string, version: number, permanent: boolean = false): Promise<number> { return await this.schemaToVersionMutex.runExclusive(async () => { let metadataValue: SchemaMetadata | undefined; this.schemaToVersionCache.forEach((value, key) => { const parsedKey = JSON...
/** * Delete a version of a subject from the Schema Registry. * @param subject - The subject to delete. * @param version - The version to delete. * @param permanent - Whether to permanently delete the version. */
https://github.com/confluentinc/confluent-kafka-javascript/blob/26710e6ec5c8ff8415f2d01dddabb811327c6cde/schemaregistry/schemaregistry-client.ts#L529-L566
26710e6ec5c8ff8415f2d01dddabb811327c6cde
confluent-kafka-javascript
github_2023
confluentinc
typescript
SchemaRegistryClient.testSubjectCompatibility
async testSubjectCompatibility(subject: string, schema: SchemaInfo): Promise<boolean> { subject = encodeURIComponent(subject); const response: AxiosResponse<isCompatibleResponse> = await this.restService.handleRequest( `/compatibility/subjects/${subject}/versions/latest`, 'POST', schema )...
/** * Test the compatibility of a schema with the latest schema for a subject. * @param subject - The subject for which to test compatibility. * @param schema - The schema to test compatibility. */
https://github.com/confluentinc/confluent-kafka-javascript/blob/26710e6ec5c8ff8415f2d01dddabb811327c6cde/schemaregistry/schemaregistry-client.ts#L573-L582
26710e6ec5c8ff8415f2d01dddabb811327c6cde
confluent-kafka-javascript
github_2023
confluentinc
typescript
SchemaRegistryClient.testCompatibility
async testCompatibility(subject: string, version: number, schema: SchemaInfo): Promise<boolean> { subject = encodeURIComponent(subject); const response: AxiosResponse<isCompatibleResponse> = await this.restService.handleRequest( `/compatibility/subjects/${subject}/versions/${version}`, 'POST', ...
/** * Test the compatibility of a schema with a specific version of a subject. * @param subject - The subject for which to test compatibility. * @param version - The version of the schema for which to test compatibility. * @param schema - The schema to test compatibility. */
https://github.com/confluentinc/confluent-kafka-javascript/blob/26710e6ec5c8ff8415f2d01dddabb811327c6cde/schemaregistry/schemaregistry-client.ts#L590-L599
26710e6ec5c8ff8415f2d01dddabb811327c6cde
confluent-kafka-javascript
github_2023
confluentinc
typescript
SchemaRegistryClient.getCompatibility
async getCompatibility(subject: string): Promise<Compatibility> { subject = encodeURIComponent(subject); const response: AxiosResponse<CompatibilityLevel> = await this.restService.handleRequest( `/config/${subject}`, 'GET' ); return response.data.compatibilityLevel!; }
/** * Get the compatibility level for a subject. * @param subject - The subject for which to get the compatibility level. */
https://github.com/confluentinc/confluent-kafka-javascript/blob/26710e6ec5c8ff8415f2d01dddabb811327c6cde/schemaregistry/schemaregistry-client.ts#L605-L613
26710e6ec5c8ff8415f2d01dddabb811327c6cde
confluent-kafka-javascript
github_2023
confluentinc
typescript
SchemaRegistryClient.updateCompatibility
async updateCompatibility(subject: string, update: Compatibility): Promise<Compatibility> { subject = encodeURIComponent(subject); const response: AxiosResponse<CompatibilityLevel> = await this.restService.handleRequest( `/config/${subject}`, 'PUT', { compatibility: update } ); return...
/** * Update the compatibility level for a subject. * @param subject - The subject for which to update the compatibility level. * @param update - The compatibility level to update to. */
https://github.com/confluentinc/confluent-kafka-javascript/blob/26710e6ec5c8ff8415f2d01dddabb811327c6cde/schemaregistry/schemaregistry-client.ts#L620-L629
26710e6ec5c8ff8415f2d01dddabb811327c6cde
confluent-kafka-javascript
github_2023
confluentinc
typescript
SchemaRegistryClient.getDefaultCompatibility
async getDefaultCompatibility(): Promise<Compatibility> { const response: AxiosResponse<CompatibilityLevel> = await this.restService.handleRequest( `/config`, 'GET' ); return response.data.compatibilityLevel!; }
/** * Get the default/global compatibility level. */
https://github.com/confluentinc/confluent-kafka-javascript/blob/26710e6ec5c8ff8415f2d01dddabb811327c6cde/schemaregistry/schemaregistry-client.ts#L634-L640
26710e6ec5c8ff8415f2d01dddabb811327c6cde
confluent-kafka-javascript
github_2023
confluentinc
typescript
SchemaRegistryClient.updateDefaultCompatibility
async updateDefaultCompatibility(update: Compatibility): Promise<Compatibility> { const response: AxiosResponse<CompatibilityLevel> = await this.restService.handleRequest( `/config`, 'PUT', { compatibility: update } ); return response.data.compatibility!; }
/** * Update the default/global compatibility level. * @param update - The compatibility level to update to. */
https://github.com/confluentinc/confluent-kafka-javascript/blob/26710e6ec5c8ff8415f2d01dddabb811327c6cde/schemaregistry/schemaregistry-client.ts#L646-L653
26710e6ec5c8ff8415f2d01dddabb811327c6cde
confluent-kafka-javascript
github_2023
confluentinc
typescript
SchemaRegistryClient.getConfig
async getConfig(subject: string): Promise<ServerConfig> { subject = encodeURIComponent(subject); const response: AxiosResponse<ServerConfig> = await this.restService.handleRequest( `/config/${subject}`, 'GET' ); return response.data; }
/** * Get the config for a subject. * @param subject - The subject for which to get the config. */
https://github.com/confluentinc/confluent-kafka-javascript/blob/26710e6ec5c8ff8415f2d01dddabb811327c6cde/schemaregistry/schemaregistry-client.ts#L659-L667
26710e6ec5c8ff8415f2d01dddabb811327c6cde
confluent-kafka-javascript
github_2023
confluentinc
typescript
SchemaRegistryClient.updateConfig
async updateConfig(subject: string, update: ServerConfig): Promise<ServerConfig> { const response: AxiosResponse<ServerConfig> = await this.restService.handleRequest( `/config/${subject}`, 'PUT', update ); return response.data; }
/** * Update the config for a subject. * @param subject - The subject for which to update the config. * @param update - The config to update to. */
https://github.com/confluentinc/confluent-kafka-javascript/blob/26710e6ec5c8ff8415f2d01dddabb811327c6cde/schemaregistry/schemaregistry-client.ts#L674-L681
26710e6ec5c8ff8415f2d01dddabb811327c6cde
confluent-kafka-javascript
github_2023
confluentinc
typescript
SchemaRegistryClient.getDefaultConfig
async getDefaultConfig(): Promise<ServerConfig> { const response: AxiosResponse<ServerConfig> = await this.restService.handleRequest( `/config`, 'GET' ); return response.data; }
/** * Get the default/global config. */
https://github.com/confluentinc/confluent-kafka-javascript/blob/26710e6ec5c8ff8415f2d01dddabb811327c6cde/schemaregistry/schemaregistry-client.ts#L686-L692
26710e6ec5c8ff8415f2d01dddabb811327c6cde
confluent-kafka-javascript
github_2023
confluentinc
typescript
SchemaRegistryClient.updateDefaultConfig
async updateDefaultConfig(update: ServerConfig): Promise<ServerConfig> { const response: AxiosResponse<ServerConfig> = await this.restService.handleRequest( `/config`, 'PUT', update ); return response.data; }
/** * Update the default/global config. * @param update - The config to update to. */
https://github.com/confluentinc/confluent-kafka-javascript/blob/26710e6ec5c8ff8415f2d01dddabb811327c6cde/schemaregistry/schemaregistry-client.ts#L698-L705
26710e6ec5c8ff8415f2d01dddabb811327c6cde
confluent-kafka-javascript
github_2023
confluentinc
typescript
SchemaRegistryClient.clearLatestCaches
clearLatestCaches(): void { this.latestToSchemaCache.clear(); this.metadataToSchemaCache.clear(); }
/** * Clear the latest caches. */
https://github.com/confluentinc/confluent-kafka-javascript/blob/26710e6ec5c8ff8415f2d01dddabb811327c6cde/schemaregistry/schemaregistry-client.ts#L710-L713
26710e6ec5c8ff8415f2d01dddabb811327c6cde
confluent-kafka-javascript
github_2023
confluentinc
typescript
SchemaRegistryClient.clearCaches
clearCaches(): void { this.schemaToIdCache.clear(); this.idToSchemaInfoCache.clear(); this.infoToSchemaCache.clear(); this.latestToSchemaCache.clear(); this.schemaToVersionCache.clear(); this.versionToSchemaCache.clear(); this.metadataToSchemaCache.clear(); }
/** * Clear all caches. */
https://github.com/confluentinc/confluent-kafka-javascript/blob/26710e6ec5c8ff8415f2d01dddabb811327c6cde/schemaregistry/schemaregistry-client.ts#L718-L726
26710e6ec5c8ff8415f2d01dddabb811327c6cde
confluent-kafka-javascript
github_2023
confluentinc
typescript
SchemaRegistryClient.close
async close(): Promise<void> { this.clearCaches(); }
/** * Close the client. */
https://github.com/confluentinc/confluent-kafka-javascript/blob/26710e6ec5c8ff8415f2d01dddabb811327c6cde/schemaregistry/schemaregistry-client.ts#L731-L733
26710e6ec5c8ff8415f2d01dddabb811327c6cde
confluent-kafka-javascript
github_2023
confluentinc
typescript
SchemaRegistryClient.addToInfoToSchemaCache
async addToInfoToSchemaCache(subject: string, schema: SchemaInfo, metadata: SchemaMetadata): Promise<void> { const cacheKey = stringify({ subject, schema: minimize(schema) }); await this.infoToSchemaMutex.runExclusive(async () => { this.infoToSchemaCache.set(cacheKey, metadata); }); }
// Cache methods for testing
https://github.com/confluentinc/confluent-kafka-javascript/blob/26710e6ec5c8ff8415f2d01dddabb811327c6cde/schemaregistry/schemaregistry-client.ts#L736-L741
26710e6ec5c8ff8415f2d01dddabb811327c6cde
confluent-kafka-javascript
github_2023
confluentinc
typescript
FieldEncryptionExecutor.register
static register(): FieldEncryptionExecutor { return this.registerWithClock(new Clock()) }
/** * Register the field encryption executor with the rule registry. */
https://github.com/confluentinc/confluent-kafka-javascript/blob/26710e6ec5c8ff8415f2d01dddabb811327c6cde/schemaregistry/rules/encryption/encrypt-executor.ts#L71-L73
26710e6ec5c8ff8415f2d01dddabb811327c6cde
confluent-kafka-javascript
github_2023
confluentinc
typescript
AwsKmsDriver.register
static register(): void { registerKmsDriver(new AwsKmsDriver()) }
/** * Register the AWS KMS driver with the KMS registry. */
https://github.com/confluentinc/confluent-kafka-javascript/blob/26710e6ec5c8ff8415f2d01dddabb811327c6cde/schemaregistry/rules/encryption/awskms/aws-driver.ts#L19-L21
26710e6ec5c8ff8415f2d01dddabb811327c6cde
confluent-kafka-javascript
github_2023
confluentinc
typescript
AzureKmsDriver.register
static register(): void { registerKmsDriver(new AzureKmsDriver()) }
/** * Register the Azure KMS driver with the KMS registry. */
https://github.com/confluentinc/confluent-kafka-javascript/blob/26710e6ec5c8ff8415f2d01dddabb811327c6cde/schemaregistry/rules/encryption/azurekms/azure-driver.ts#L15-L17
26710e6ec5c8ff8415f2d01dddabb811327c6cde
confluent-kafka-javascript
github_2023
confluentinc
typescript
DekRegistryClient.checkLatestDekInCache
async checkLatestDekInCache(kekName: string, subject: string, algorithm: string): Promise<boolean> { const cacheKey = stringify({ kekName, subject, version: -1, algorithm, deleted: false }); const cachedDek = this.dekCache.get(cacheKey); return cachedDek !== undefined; }
//Cache methods for testing
https://github.com/confluentinc/confluent-kafka-javascript/blob/26710e6ec5c8ff8415f2d01dddabb811327c6cde/schemaregistry/rules/encryption/dekregistry/dekregistry-client.ts#L246-L250
26710e6ec5c8ff8415f2d01dddabb811327c6cde
confluent-kafka-javascript
github_2023
confluentinc
typescript
GcpKmsDriver.register
static register(): void { registerKmsDriver(new GcpKmsDriver()) }
/** * Register the GCP KMS driver with the KMS registry. */
https://github.com/confluentinc/confluent-kafka-javascript/blob/26710e6ec5c8ff8415f2d01dddabb811327c6cde/schemaregistry/rules/encryption/gcpkms/gcp-driver.ts#L16-L18
26710e6ec5c8ff8415f2d01dddabb811327c6cde
confluent-kafka-javascript
github_2023
confluentinc
typescript
HcVaultDriver.register
static register(): void { registerKmsDriver(new HcVaultDriver()) }
/** * Register the HashiCorp Vault driver with the KMS registry. */
https://github.com/confluentinc/confluent-kafka-javascript/blob/26710e6ec5c8ff8415f2d01dddabb811327c6cde/schemaregistry/rules/encryption/hcvault/hcvault-driver.ts#L13-L15
26710e6ec5c8ff8415f2d01dddabb811327c6cde
confluent-kafka-javascript
github_2023
confluentinc
typescript
LocalKmsDriver.register
static register(): void { registerKmsDriver(new LocalKmsDriver()) }
/** * Register the local KMS driver with the KMS registry. */
https://github.com/confluentinc/confluent-kafka-javascript/blob/26710e6ec5c8ff8415f2d01dddabb811327c6cde/schemaregistry/rules/encryption/localkms/local-driver.ts#L12-L14
26710e6ec5c8ff8415f2d01dddabb811327c6cde
confluent-kafka-javascript
github_2023
confluentinc
typescript
AesGcm.encrypt
async encrypt(plaintext: Uint8Array, associatedData?: Uint8Array): Promise<Uint8Array> { Validators.requireUint8Array(plaintext); if (associatedData != null) { Validators.requireUint8Array(associatedData); } const iv = Random.randBytes(IV_SIZE_IN_BYTES); const alg: AesGcmParams = { ...
/** */
https://github.com/confluentinc/confluent-kafka-javascript/blob/26710e6ec5c8ff8415f2d01dddabb811327c6cde/schemaregistry/rules/encryption/tink/aes_gcm.ts#L37-L55
26710e6ec5c8ff8415f2d01dddabb811327c6cde
confluent-kafka-javascript
github_2023
confluentinc
typescript
AesGcm.decrypt
async decrypt(ciphertext: Uint8Array, associatedData?: Uint8Array): Promise<Uint8Array> { Validators.requireUint8Array(ciphertext); if (ciphertext.length < IV_SIZE_IN_BYTES + TAG_SIZE_IN_BITS / 8) { throw new SecurityException('ciphertext too short'); } if (associatedData != null) { Va...
/** */
https://github.com/confluentinc/confluent-kafka-javascript/blob/26710e6ec5c8ff8415f2d01dddabb811327c6cde/schemaregistry/rules/encryption/tink/aes_gcm.ts#L59-L88
26710e6ec5c8ff8415f2d01dddabb811327c6cde
confluent-kafka-javascript
github_2023
confluentinc
typescript
AesSiv.encrypt
async encrypt(plaintext: Uint8Array, associatedData?: Uint8Array): Promise<Uint8Array> { let key = await SIV.importKey(this.key, "AES-CMAC-SIV", new SoftCryptoProvider()); return key.seal(plaintext, associatedData != null ? [associatedData] : []); }
/** */
https://github.com/confluentinc/confluent-kafka-javascript/blob/26710e6ec5c8ff8415f2d01dddabb811327c6cde/schemaregistry/rules/encryption/tink/aes_siv.ts#L22-L26
26710e6ec5c8ff8415f2d01dddabb811327c6cde
confluent-kafka-javascript
github_2023
confluentinc
typescript
AesSiv.decrypt
async decrypt(ciphertext: Uint8Array, associatedData?: Uint8Array): Promise<Uint8Array> { let key = await SIV.importKey(this.key, "AES-CMAC-SIV", new SoftCryptoProvider()); return key.open(ciphertext, associatedData != null? [associatedData] : []); }
/** */
https://github.com/confluentinc/confluent-kafka-javascript/blob/26710e6ec5c8ff8415f2d01dddabb811327c6cde/schemaregistry/rules/encryption/tink/aes_siv.ts#L30-L34
26710e6ec5c8ff8415f2d01dddabb811327c6cde
confluent-kafka-javascript
github_2023
confluentinc
typescript
Hmac.constructor
constructor( private readonly hash: string, private readonly key: CryptoKey, private readonly tagSize: number) { super(); }
/** * @param hash - accepted names are SHA-1, SHA-256 and SHA-512 * @param tagSize - the size of the tag */
https://github.com/confluentinc/confluent-kafka-javascript/blob/26710e6ec5c8ff8415f2d01dddabb811327c6cde/schemaregistry/rules/encryption/tink/hmac.ts#L28-L32
26710e6ec5c8ff8415f2d01dddabb811327c6cde
confluent-kafka-javascript
github_2023
confluentinc
typescript
Hmac.computeMac
async computeMac(data: Uint8Array): Promise<Uint8Array> { Validators.requireUint8Array(data); const tag = await crypto.subtle.sign( {'name': 'HMAC', 'hash': {'name': this.hash}}, this.key, data); return new Uint8Array(tag.slice(0, this.tagSize)); }
/** */
https://github.com/confluentinc/confluent-kafka-javascript/blob/26710e6ec5c8ff8415f2d01dddabb811327c6cde/schemaregistry/rules/encryption/tink/hmac.ts#L36-L41
26710e6ec5c8ff8415f2d01dddabb811327c6cde
confluent-kafka-javascript
github_2023
confluentinc
typescript
Hmac.verifyMac
async verifyMac(tag: Uint8Array, data: Uint8Array): Promise<boolean> { Validators.requireUint8Array(tag); Validators.requireUint8Array(data); const computedTag = await this.computeMac(data); return Bytes.isEqual(tag, computedTag); }
/** */
https://github.com/confluentinc/confluent-kafka-javascript/blob/26710e6ec5c8ff8415f2d01dddabb811327c6cde/schemaregistry/rules/encryption/tink/hmac.ts#L45-L50
26710e6ec5c8ff8415f2d01dddabb811327c6cde
confluent-kafka-javascript
github_2023
confluentinc
typescript
JsonataExecutor.register
static register(): JsonataExecutor { const executor = new JsonataExecutor() RuleRegistry.registerRuleExecutor(executor) return executor }
/** * Register the JSONata rule executor with the rule registry. */
https://github.com/confluentinc/confluent-kafka-javascript/blob/26710e6ec5c8ff8415f2d01dddabb811327c6cde/schemaregistry/rules/jsonata/jsonata-executor.ts#L14-L18
26710e6ec5c8ff8415f2d01dddabb811327c6cde
confluent-kafka-javascript
github_2023
confluentinc
typescript
AvroSerializer.constructor
constructor(client: Client, serdeType: SerdeType, conf: AvroSerializerConfig, ruleRegistry?: RuleRegistry) { super(client, serdeType, conf, ruleRegistry) this.schemaToTypeCache = new LRUCache<string, [Type, Map<string, string>]>({ max: this.conf.cacheCapacity ?? 1000 }) this.fieldTransformer = async (ctx: R...
/** * Create a new AvroSerializer. * @param client - the schema registry client * @param serdeType - the type of the serializer * @param conf - the serializer configuration * @param ruleRegistry - the rule registry */
https://github.com/confluentinc/confluent-kafka-javascript/blob/26710e6ec5c8ff8415f2d01dddabb811327c6cde/schemaregistry/serde/avro.ts#L50-L59
26710e6ec5c8ff8415f2d01dddabb811327c6cde
confluent-kafka-javascript
github_2023
confluentinc
typescript
AvroSerializer.serialize
override async serialize(topic: string, msg: any): Promise<Buffer> { if (this.client == null) { throw new Error('client is not initialized') } if (msg == null) { throw new Error('message is empty') } let schema: SchemaInfo | undefined = undefined // Don't derive the schema if it is ...
/** * serialize is used to serialize a message using Avro. * @param topic - the topic to serialize the message for * @param msg - the message to serialize */
https://github.com/confluentinc/confluent-kafka-javascript/blob/26710e6ec5c8ff8415f2d01dddabb811327c6cde/schemaregistry/serde/avro.ts#L66-L94
26710e6ec5c8ff8415f2d01dddabb811327c6cde
confluent-kafka-javascript
github_2023
confluentinc
typescript
AvroDeserializer.constructor
constructor(client: Client, serdeType: SerdeType, conf: AvroDeserializerConfig, ruleRegistry?: RuleRegistry) { super(client, serdeType, conf, ruleRegistry) this.schemaToTypeCache = new LRUCache<string, [Type, Map<string, string>]>({ max: this.conf.cacheCapacity ?? 1000 }) this.fieldTransformer = async (ctx:...
/** * Create a new AvroDeserializer. * @param client - the schema registry client * @param serdeType - the type of the deserializer * @param conf - the deserializer configuration * @param ruleRegistry - the rule registry */
https://github.com/confluentinc/confluent-kafka-javascript/blob/26710e6ec5c8ff8415f2d01dddabb811327c6cde/schemaregistry/serde/avro.ts#L156-L165
26710e6ec5c8ff8415f2d01dddabb811327c6cde
confluent-kafka-javascript
github_2023
confluentinc
typescript
getInlineTagsRecursively
function getInlineTagsRecursively(ns: string, name: string, schema: any, tags: Map<string, Set<string>>): void { if (schema == null || typeof schema === 'string') { return } else if (Array.isArray(schema)) { for (let i = 0; i < schema.length; i++) { getInlineTagsRecursively(ns, name, schema[i], tags) ...
// iterate over the object and get all properties named 'confluent:tags'
https://github.com/confluentinc/confluent-kafka-javascript/blob/26710e6ec5c8ff8415f2d01dddabb811327c6cde/schemaregistry/serde/avro.ts#L424-L467
26710e6ec5c8ff8415f2d01dddabb811327c6cde
confluent-kafka-javascript
github_2023
confluentinc
typescript
BufferWrapper.writeVarInt
writeVarInt(n: number): void { let f, m if (n >= -1073741824 && n < 1073741824) { // Won't overflow, we can use integer arithmetic. m = n >= 0 ? n << 1 : (~n << 1) | 1 do { this.buf[this.pos] = m & 0x7f m >>= 7 } while (m && (this.buf[this.pos++] |= 0x80)) } else { ...
// Adapted from avro-js
https://github.com/confluentinc/confluent-kafka-javascript/blob/26710e6ec5c8ff8415f2d01dddabb811327c6cde/schemaregistry/serde/buffer-wrapper.ts#L15-L34
26710e6ec5c8ff8415f2d01dddabb811327c6cde
confluent-kafka-javascript
github_2023
confluentinc
typescript
BufferWrapper.readVarInt
readVarInt(): number { let n = 0 let k = 0 let b, h, f, fk do { b = this.buf[this.pos++] h = b & 0x80 n |= (b & 0x7f) << k k += 7 } while (h && k < 28) if (h) { // Switch to float arithmetic, otherwise we might overflow. f = n fk = 268435456 // 2 ** 28...
// Adapted from avro-js
https://github.com/confluentinc/confluent-kafka-javascript/blob/26710e6ec5c8ff8415f2d01dddabb811327c6cde/schemaregistry/serde/buffer-wrapper.ts#L37-L62
26710e6ec5c8ff8415f2d01dddabb811327c6cde
confluent-kafka-javascript
github_2023
confluentinc
typescript
JsonSerializer.constructor
constructor(client: Client, serdeType: SerdeType, conf: JsonSerializerConfig, ruleRegistry?: RuleRegistry) { super(client, serdeType, conf, ruleRegistry) this.schemaToTypeCache = new LRUCache<string, DereferencedJSONSchema>({ max: this.config().cacheCapacity ?? 1000 }) this.schemaToValidateCache = new LRUCa...
/** * Creates a new JsonSerializer. * @param client - the schema registry client * @param serdeType - the serializer type * @param conf - the serializer configuration * @param ruleRegistry - the rule registry */
https://github.com/confluentinc/confluent-kafka-javascript/blob/26710e6ec5c8ff8415f2d01dddabb811327c6cde/schemaregistry/serde/json.ts#L69-L79
26710e6ec5c8ff8415f2d01dddabb811327c6cde
confluent-kafka-javascript
github_2023
confluentinc
typescript
JsonSerializer.serialize
override async serialize(topic: string, msg: any): Promise<Buffer> { if (this.client == null) { throw new Error('client is not initialized') } if (msg == null) { throw new Error('message is empty') } let schema: SchemaInfo | undefined = undefined // Don't derive the schema if it is ...
/** * Serializes a message. * @param topic - the topic * @param msg - the message */
https://github.com/confluentinc/confluent-kafka-javascript/blob/26710e6ec5c8ff8415f2d01dddabb811327c6cde/schemaregistry/serde/json.ts#L86-L116
26710e6ec5c8ff8415f2d01dddabb811327c6cde
confluent-kafka-javascript
github_2023
confluentinc
typescript
JsonDeserializer.constructor
constructor(client: Client, serdeType: SerdeType, conf: JsonDeserializerConfig, ruleRegistry?: RuleRegistry) { super(client, serdeType, conf, ruleRegistry) this.schemaToTypeCache = new LRUCache<string, DereferencedJSONSchema>({ max: this.config().cacheCapacity ?? 1000 }) this.schemaToValidateCache = new LRU...
/** * Creates a new JsonDeserializer. * @param client - the schema registry client * @param serdeType - the deserializer type * @param conf - the deserializer configuration * @param ruleRegistry - the rule registry */
https://github.com/confluentinc/confluent-kafka-javascript/blob/26710e6ec5c8ff8415f2d01dddabb811327c6cde/schemaregistry/serde/json.ts#L167-L177
26710e6ec5c8ff8415f2d01dddabb811327c6cde
confluent-kafka-javascript
github_2023
confluentinc
typescript
JsonDeserializer.deserialize
override async deserialize(topic: string, payload: Buffer): Promise<any> { if (!Buffer.isBuffer(payload)) { throw new Error('Invalid buffer') } if (payload.length === 0) { return null } const info = await this.getSchema(topic, payload) const subject = this.subjectName(topic, info) ...
/** * Deserializes a message. * @param topic - the topic * @param payload - the message payload */
https://github.com/confluentinc/confluent-kafka-javascript/blob/26710e6ec5c8ff8415f2d01dddabb811327c6cde/schemaregistry/serde/json.ts#L184-L218
26710e6ec5c8ff8415f2d01dddabb811327c6cde
confluent-kafka-javascript
github_2023
confluentinc
typescript
ProtobufSerializer.constructor
constructor(client: Client, serdeType: SerdeType, conf: ProtobufSerializerConfig, ruleRegistry?: RuleRegistry) { super(client, serdeType, conf, ruleRegistry) this.registry = conf.registry ?? createMutableRegistry() this.fileRegistry = createFileRegistry() this.schemaToDescCache = new LRUCache<string, De...
/** * Creates a new ProtobufSerializer. * @param client - the schema registry client * @param serdeType - the serializer type * @param conf - the serializer configuration * @param ruleRegistry - the rule registry */
https://github.com/confluentinc/confluent-kafka-javascript/blob/26710e6ec5c8ff8415f2d01dddabb811327c6cde/schemaregistry/serde/protobuf.ts#L117-L129
26710e6ec5c8ff8415f2d01dddabb811327c6cde
confluent-kafka-javascript
github_2023
confluentinc
typescript
ProtobufSerializer.serialize
override async serialize(topic: string, msg: any): Promise<Buffer> { if (this.client == null) { throw new Error('client is not initialized') } if (msg == null) { throw new Error('message is empty') } const typeName = msg.$typeName if (typeName == null) { throw new Serializatio...
/** * Serializes a message. * @param topic - the topic * @param msg - the message */
https://github.com/confluentinc/confluent-kafka-javascript/blob/26710e6ec5c8ff8415f2d01dddabb811327c6cde/schemaregistry/serde/protobuf.ts#L136-L167
26710e6ec5c8ff8415f2d01dddabb811327c6cde
confluent-kafka-javascript
github_2023
confluentinc
typescript
ProtobufDeserializer.constructor
constructor(client: Client, serdeType: SerdeType, conf: ProtobufDeserializerConfig, ruleRegistry?: RuleRegistry) { super(client, serdeType, conf, ruleRegistry) this.fileRegistry = createFileRegistry() this.schemaToDescCache = new LRUCache<string, DescFile>({ max: this.config().cacheCapacity ?? 1000 } ) ...
/** * Creates a new ProtobufDeserializer. * @param client - the schema registry client * @param serdeType - the deserializer type * @param conf - the deserializer configuration * @param ruleRegistry - the rule registry */
https://github.com/confluentinc/confluent-kafka-javascript/blob/26710e6ec5c8ff8415f2d01dddabb811327c6cde/schemaregistry/serde/protobuf.ts#L353-L363
26710e6ec5c8ff8415f2d01dddabb811327c6cde
confluent-kafka-javascript
github_2023
confluentinc
typescript
ProtobufDeserializer.deserialize
override async deserialize(topic: string, payload: Buffer): Promise<any> { if (!Buffer.isBuffer(payload)) { throw new Error('Invalid buffer') } if (payload.length === 0) { return null } const info = await this.getSchema(topic, payload, 'serialized') const fd = await this.toFileDesc(...
/** * Deserializes a message. * @param topic - the topic * @param payload - the message payload */
https://github.com/confluentinc/confluent-kafka-javascript/blob/26710e6ec5c8ff8415f2d01dddabb811327c6cde/schemaregistry/serde/protobuf.ts#L370-L399
26710e6ec5c8ff8415f2d01dddabb811327c6cde
confluent-kafka-javascript
github_2023
confluentinc
typescript
RuleRegistry.registerExecutor
public registerExecutor(ruleExecutor: RuleExecutor): void { this.ruleExecutors.set(ruleExecutor.type(), ruleExecutor) }
/** * registerExecutor is used to register a new rule executor. * @param ruleExecutor - the rule executor to register */
https://github.com/confluentinc/confluent-kafka-javascript/blob/26710e6ec5c8ff8415f2d01dddabb811327c6cde/schemaregistry/serde/rule-registry.ts#L27-L29
26710e6ec5c8ff8415f2d01dddabb811327c6cde
confluent-kafka-javascript
github_2023
confluentinc
typescript
RuleRegistry.getExecutor
public getExecutor(name: string): RuleExecutor | undefined { return this.ruleExecutors.get(name) }
/** * getExecutor fetches a rule executor by a given name. * @param name - the name of the rule executor to fetch */
https://github.com/confluentinc/confluent-kafka-javascript/blob/26710e6ec5c8ff8415f2d01dddabb811327c6cde/schemaregistry/serde/rule-registry.ts#L35-L37
26710e6ec5c8ff8415f2d01dddabb811327c6cde
confluent-kafka-javascript
github_2023
confluentinc
typescript
RuleRegistry.getExecutors
public getExecutors(): RuleExecutor[] { return Array.from(this.ruleExecutors.values()) }
/** * getExecutors fetches all rule executors */
https://github.com/confluentinc/confluent-kafka-javascript/blob/26710e6ec5c8ff8415f2d01dddabb811327c6cde/schemaregistry/serde/rule-registry.ts#L42-L44
26710e6ec5c8ff8415f2d01dddabb811327c6cde
confluent-kafka-javascript
github_2023
confluentinc
typescript
RuleRegistry.registerAction
public registerAction(ruleAction: RuleAction): void { this.ruleActions.set(ruleAction.type(), ruleAction) }
/** * registerAction is used to register a new rule action. * @param ruleAction - the rule action to register */
https://github.com/confluentinc/confluent-kafka-javascript/blob/26710e6ec5c8ff8415f2d01dddabb811327c6cde/schemaregistry/serde/rule-registry.ts#L50-L52
26710e6ec5c8ff8415f2d01dddabb811327c6cde
confluent-kafka-javascript
github_2023
confluentinc
typescript
RuleRegistry.getAction
public getAction(name: string): RuleAction | undefined { return this.ruleActions.get(name) }
/** * getAction fetches a rule action by a given name. * @param name - the name of the rule action to fetch */
https://github.com/confluentinc/confluent-kafka-javascript/blob/26710e6ec5c8ff8415f2d01dddabb811327c6cde/schemaregistry/serde/rule-registry.ts#L58-L60
26710e6ec5c8ff8415f2d01dddabb811327c6cde
confluent-kafka-javascript
github_2023
confluentinc
typescript
RuleRegistry.getActions
public getActions(): RuleAction[] { return Array.from(this.ruleActions.values()) }
/** * getActions fetches all rule actions */
https://github.com/confluentinc/confluent-kafka-javascript/blob/26710e6ec5c8ff8415f2d01dddabb811327c6cde/schemaregistry/serde/rule-registry.ts#L65-L67
26710e6ec5c8ff8415f2d01dddabb811327c6cde
confluent-kafka-javascript
github_2023
confluentinc
typescript
RuleRegistry.registerOverride
public registerOverride(ruleOverride: RuleOverride): void { this.ruleOverrides.set(ruleOverride.type, ruleOverride) }
/** * registerOverride is used to register a new rule override. * @param ruleOverride - the rule override to register */
https://github.com/confluentinc/confluent-kafka-javascript/blob/26710e6ec5c8ff8415f2d01dddabb811327c6cde/schemaregistry/serde/rule-registry.ts#L73-L75
26710e6ec5c8ff8415f2d01dddabb811327c6cde
confluent-kafka-javascript
github_2023
confluentinc
typescript
RuleRegistry.getOverride
public getOverride(name: string): RuleOverride | undefined { return this.ruleOverrides.get(name) }
/** * getOverride fetches a rule override by a given name. * @param name - the name of the rule override to fetch */
https://github.com/confluentinc/confluent-kafka-javascript/blob/26710e6ec5c8ff8415f2d01dddabb811327c6cde/schemaregistry/serde/rule-registry.ts#L81-L83
26710e6ec5c8ff8415f2d01dddabb811327c6cde
confluent-kafka-javascript
github_2023
confluentinc
typescript
RuleRegistry.getOverrides
public getOverrides(): RuleOverride[] { return Array.from(this.ruleOverrides.values()) }
/** * getOverrides fetches all rule overrides */
https://github.com/confluentinc/confluent-kafka-javascript/blob/26710e6ec5c8ff8415f2d01dddabb811327c6cde/schemaregistry/serde/rule-registry.ts#L88-L90
26710e6ec5c8ff8415f2d01dddabb811327c6cde
confluent-kafka-javascript
github_2023
confluentinc
typescript
RuleRegistry.clear
public clear(): void { this.ruleExecutors.clear() this.ruleActions.clear() this.ruleOverrides.clear() }
/** * clear clears all registered rules */
https://github.com/confluentinc/confluent-kafka-javascript/blob/26710e6ec5c8ff8415f2d01dddabb811327c6cde/schemaregistry/serde/rule-registry.ts#L95-L99
26710e6ec5c8ff8415f2d01dddabb811327c6cde
confluent-kafka-javascript
github_2023
confluentinc
typescript
RuleRegistry.getGlobalInstance
public static getGlobalInstance(): RuleRegistry { return RuleRegistry.globalInstance }
/** * getGlobalInstance fetches the global instance of the rule registry */
https://github.com/confluentinc/confluent-kafka-javascript/blob/26710e6ec5c8ff8415f2d01dddabb811327c6cde/schemaregistry/serde/rule-registry.ts#L104-L106
26710e6ec5c8ff8415f2d01dddabb811327c6cde
confluent-kafka-javascript
github_2023
confluentinc
typescript
RuleRegistry.registerRuleExecutor
public static registerRuleExecutor(ruleExecutor: RuleExecutor): void { RuleRegistry.globalInstance.registerExecutor(ruleExecutor) }
/** * registerRuleExecutor is used to register a new rule executor globally. * @param ruleExecutor - the rule executor to register */
https://github.com/confluentinc/confluent-kafka-javascript/blob/26710e6ec5c8ff8415f2d01dddabb811327c6cde/schemaregistry/serde/rule-registry.ts#L112-L114
26710e6ec5c8ff8415f2d01dddabb811327c6cde
confluent-kafka-javascript
github_2023
confluentinc
typescript
RuleRegistry.registerRuleAction
public static registerRuleAction(ruleAction: RuleAction): void { RuleRegistry.globalInstance.registerAction(ruleAction) }
/** * registerRuleAction is used to register a new rule action globally. * @param ruleAction - the rule action to register */
https://github.com/confluentinc/confluent-kafka-javascript/blob/26710e6ec5c8ff8415f2d01dddabb811327c6cde/schemaregistry/serde/rule-registry.ts#L120-L122
26710e6ec5c8ff8415f2d01dddabb811327c6cde
confluent-kafka-javascript
github_2023
confluentinc
typescript
RuleRegistry.registerRuleOverride
public static registerRuleOverride(ruleOverride: RuleOverride): void { RuleRegistry.globalInstance.registerOverride(ruleOverride) }
/** * registerRuleOverride is used to register a new rule override globally. * @param ruleOverride - the rule override to register */
https://github.com/confluentinc/confluent-kafka-javascript/blob/26710e6ec5c8ff8415f2d01dddabb811327c6cde/schemaregistry/serde/rule-registry.ts#L128-L130
26710e6ec5c8ff8415f2d01dddabb811327c6cde
confluent-kafka-javascript
github_2023
confluentinc
typescript
RuleError.constructor
constructor(message?: string) { super(message) }
/** * Creates a new rule error. * @param message - The error message. */
https://github.com/confluentinc/confluent-kafka-javascript/blob/26710e6ec5c8ff8415f2d01dddabb811327c6cde/schemaregistry/serde/serde.ts#L25-L27
26710e6ec5c8ff8415f2d01dddabb811327c6cde
confluent-kafka-javascript
github_2023
confluentinc
typescript
RuleConditionError.constructor
constructor(rule: Rule) { super(RuleConditionError.error(rule)) this.rule = rule }
/** * Creates a new rule condition error. * @param rule - The rule. */
https://github.com/confluentinc/confluent-kafka-javascript/blob/26710e6ec5c8ff8415f2d01dddabb811327c6cde/schemaregistry/serde/serde.ts#L805-L808
26710e6ec5c8ff8415f2d01dddabb811327c6cde
clash-nyanpasu
github_2023
libnyanpasu
typescript
upsert
const upsert = async (value: IVerge[K]) => { if (!data) { return } await update.mutateAsync({ [key]: value }) }
/** * Updates a specific setting value in the Verge configuration * @param value - The new value to be set for the specified key * @returns void * @remarks This function will not execute if the data is not available */
https://github.com/libnyanpasu/clash-nyanpasu/blob/ac0d0fc2b7e28c99d9d635fe89be6673597749ca/frontend/interface/src/ipc/use-settings.ts#L116-L122
ac0d0fc2b7e28c99d9d635fe89be6673597749ca
clash-nyanpasu
github_2023
libnyanpasu
typescript
uploadAssets
async function uploadAssets(releaseId: number, assets: string[]) { const GITHUB_TOKEN = process.env.GITHUB_TOKEN if (!GITHUB_TOKEN) { throw new Error('GITHUB_TOKEN is required') } const github = getOctokit(GITHUB_TOKEN) // Determine content-length for header to upload asset const contentLength = (fileP...
// From tauri-apps/tauri-action
https://github.com/libnyanpasu/clash-nyanpasu/blob/ac0d0fc2b7e28c99d9d635fe89be6673597749ca/scripts/osx-aarch64-upload.ts#L66-L109
ac0d0fc2b7e28c99d9d635fe89be6673597749ca
clash-nyanpasu
github_2023
libnyanpasu
typescript
contentLength
const contentLength = (filePath: string) => fs.statSync(filePath).size
// Determine content-length for header to upload asset
https://github.com/libnyanpasu/clash-nyanpasu/blob/ac0d0fc2b7e28c99d9d635fe89be6673597749ca/scripts/osx-aarch64-upload.ts#L74-L74
ac0d0fc2b7e28c99d9d635fe89be6673597749ca
clash-nyanpasu
github_2023
libnyanpasu
typescript
resolvePortable
async function resolvePortable() { if (process.platform !== 'win32') return const buildDir = path.join( RUST_ARCH === 'x86_64' ? 'backend/target/release' : `backend/target/${RUST_ARCH}-pc-windows-msvc/release`, ) const configDir = path.join(buildDir, '.config') if (!(await fs.pathExists(bui...
/// Script for ci
https://github.com/libnyanpasu/clash-nyanpasu/blob/ac0d0fc2b7e28c99d9d635fe89be6673597749ca/scripts/portable.ts#L14-L92
ac0d0fc2b7e28c99d9d635fe89be6673597749ca
clash-nyanpasu
github_2023
libnyanpasu
typescript
resolvePublish
async function resolvePublish() { const flag = process.argv[2] ?? 'patch' const tauriJson = await fs.readJSON(TAURI_APP_CONF_PATH) const tauriNightlyJson = await fs.readJSON(TAURI_NIGHTLY_APP_CONF_PATH) let [a, b, c] = packageJson.version.split('.').map(Number) if (flag === 'major') { a += 1 b = 0 ...
// publish
https://github.com/libnyanpasu/clash-nyanpasu/blob/ac0d0fc2b7e28c99d9d635fe89be6673597749ca/scripts/publish.ts#L23-L79
ac0d0fc2b7e28c99d9d635fe89be6673597749ca
clash-nyanpasu
github_2023
libnyanpasu
typescript
resolveUpdater
async function resolveUpdater() { if (process.env.GITHUB_TOKEN === undefined) { throw new Error('GITHUB_TOKEN is required') } consola.start('start to generate updater files') const options = { owner: context.repo.owner, repo: context.repo.repo, } const github = getOctokit(process.env.GITHUB_TOKE...
/// generate update.json
https://github.com/libnyanpasu/clash-nyanpasu/blob/ac0d0fc2b7e28c99d9d635fe89be6673597749ca/scripts/updater-nightly.ts#L33-L261
ac0d0fc2b7e28c99d9d635fe89be6673597749ca
clash-nyanpasu
github_2023
libnyanpasu
typescript
getSignature
async function getSignature(url: string) { const response = await fetch(url, { method: 'GET', headers: { 'Content-Type': 'application/octet-stream' }, }) return response.text() }
// get the signature file content
https://github.com/libnyanpasu/clash-nyanpasu/blob/ac0d0fc2b7e28c99d9d635fe89be6673597749ca/scripts/updater-nightly.ts#L276-L283
ac0d0fc2b7e28c99d9d635fe89be6673597749ca
clash-nyanpasu
github_2023
libnyanpasu
typescript
resolveUpdater
async function resolveUpdater() { if (process.env.GITHUB_TOKEN === undefined) { throw new Error('GITHUB_TOKEN is required') } const options = { owner: context.repo.owner, repo: context.repo.repo } const github = getOctokit(process.env.GITHUB_TOKEN) const { data: tags } = await github.rest.repos.listTags...
/// generate update.json
https://github.com/libnyanpasu/clash-nyanpasu/blob/ac0d0fc2b7e28c99d9d635fe89be6673597749ca/scripts/updater.ts#L32-L250
ac0d0fc2b7e28c99d9d635fe89be6673597749ca
clash-nyanpasu
github_2023
libnyanpasu
typescript
getSignature
async function getSignature(url: string) { const response = await fetch(url, { method: 'GET', headers: { 'Content-Type': 'application/octet-stream' }, }) return response.text() }
// get the signature file content
https://github.com/libnyanpasu/clash-nyanpasu/blob/ac0d0fc2b7e28c99d9d635fe89be6673597749ca/scripts/updater.ts#L266-L273
ac0d0fc2b7e28c99d9d635fe89be6673597749ca
clash-nyanpasu
github_2023
libnyanpasu
typescript
Resolve.wintun
public async wintun() { const { platform } = process let arch: string = this.options.arch || 'x64' if (platform !== 'win32') return switch (arch) { case 'x64': arch = 'amd64' break case 'ia32': arch = 'x86' break case 'arm': arch = 'arm' ...
/** * only Windows * get the wintun.dll (not required) */
https://github.com/libnyanpasu/clash-nyanpasu/blob/ac0d0fc2b7e28c99d9d635fe89be6673597749ca/scripts/utils/resolve.ts#L67-L146
ac0d0fc2b7e28c99d9d635fe89be6673597749ca
sun-panel
github_2023
hslr-s
typescript
naiveStyleOverride
function naiveStyleOverride() { const meta = document.createElement('meta') meta.name = 'naive-ui-style' document.head.appendChild(meta) }
/** Tailwind's Preflight Style Override */
https://github.com/hslr-s/sun-panel/blob/25f46209d97ae7bd6de29c39f93fd4d83932eb06/src/plugins/assets.ts#L8-L12
25f46209d97ae7bd6de29c39f93fd4d83932eb06