kinddiff

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 27, 2026 License: Apache-2.0, MIT Imports: 13 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package kinddiff compares two versions of a kind of request from their requests directories: the kind's description in types/<kind>.json, and the operations the kind owns in openapi.json. It uses the standard library alone.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Diff

type Diff struct {
	Kind       string
	OldVersion int
	NewVersion int
	NewKind    bool
	// contains filtered or unexported fields
}

Diff is what differs between two versions of a kind. OldVersion is 0 for a new kind.

func Compare

func Compare(old, new fs.FS, kind string) (*Diff, error)

Compare reads types/<kind>.json and the kind's operations in openapi.json from two requests directories and answers what changed. A nil old means the kind is new. It refuses a directory without the kind, a description that does not read, and two descriptions of different kinds.

Example
package main

import (
	"fmt"
	"os"
	"path/filepath"

	"github.com/i2y/ringi-server/kinddiff"
)

func main() {
	oldDir := os.DirFS(filepath.Join("testdata", "v1"))
	newDir := os.DirFS(filepath.Join("testdata", "v2"))
	d, err := kinddiff.Compare(oldDir, newDir, "leave")
	if err != nil {
		panic(err)
	}
	for _, line := range d.Lines("en") {
		fmt.Printf("%s api=%v: %s\n", line.Section, line.API, line.Text)
	}
	for _, line := range d.Lines("ja") {
		fmt.Printf("%s api=%v: %s\n", line.Section, line.API, line.Text)
	}
}
Output:
form api=true: The number range of the field "Business days" (days) changes from 1 through 20 to 1 through 25.
usable api=false: This version now takes effect from 2027-04-01.
usable api=false: The first day the kind can be used changes from 2026-04-01 to 2027-04-01.
usable api=false: The data deciding the first day the kind can be used changes from "the first version of the organization `shared/company.ringi` (data `../org`)" to "`effective from`".
api api=true: In the request body of `submit_leave`, `maximum` of `form.days` changes from `20` to `25`.
api api=true: In the request body of `resubmit_leave`, `maximum` of `form.days` changes from `20` to `25`.
form api=true: 項目「営業日の日数」(days)の数値の範囲が1以上20以下から1以上25以下に変わります。
usable api=false: この版は2027-04-01から効きます。
usable api=false: この申請の種類を出せる最初の日が2026-04-01から2027-04-01に変わります。
usable api=false: 申請を出せる最初の日を決めるデータが「the first version of the organization `shared/company.ringi` (data `../org`)」から「`effective from`」に変わります。
api api=true: `submit_leave` に送る本文では、`form.days` の `maximum` が`20`から`25`に変わります。
api api=true: `resubmit_leave` に送る本文では、`form.days` の `maximum` が`20`から`25`に変わります。

func (*Diff) APIChanged

func (d *Diff) APIChanged() bool

APIChanged reports whether any operation of the kind takes or answers a different shape, or an operation of the kind is added or removed.

func (*Diff) Lines

func (d *Diff) Lines(lang string) []Line

Lines answers the changes as sentences in English or Japanese. Japanese is chosen by "ja"; every other language is answered in English, as the framework's other language choices do.

type Line

type Line struct {
	Section string
	Text    string
	API     bool
}

Line is one change as an administrator reads it. Section is one of "form", "stages", "approvers", "usable", "api" and "other". API is true of the lines found by comparing the kind's OpenAPI operations: the lines that say the shape a client sends or receives changed.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL